Apple Interview Question

median for a stream

Interview Answers

Anonymous

Apr 18, 2018

I think you are right. I had similar interview experience as yours.

Anonymous

Dec 13, 2018

Dude you're so wrong! I guess you have no idea, how difficult it is for Indians in the interview. As an Indian, as soon as I see an Indian interviewer, I know my interview have came to an end. So, don't sweat on it, their attitude is consistently inconsistent. I think these foos have a point to prove. lol. Don't get disheartened, and I wanna assure not everyone is mean. Good luck!

Anonymous

Aug 6, 2019

I am a indian too and i had the same problem there! I hated it!

Anonymous

Oct 26, 2017

DoubleStream sortedStream = list.stream()).sorted(); //if odd, get the average of middle two, else get the middle first value double median = list.size()%2 == 0? sortedStream.skip(list.size()/2-1).limit(2).average().getAsDouble(): sortedStream.skip(list.size()/2).findFirst().getAsDouble();