Amazon.com Interview Question
1,572 Interview Reviews |
Back to all Amazon.com Interview Questions & Reviews
Interview questions and reviews posted anonymously by interview candidates
Interview Question for Software Development Engineer II at Amazon.com:
Find k largest/smallest number in a series of numbers. What data-structures will you use? Code it on white board.
| Tags: | c++, c See more , See less 8 |
See more for this Amazon.com Software Development Engineer II Interview
Helpful Question?
Yes |
No
Inappropriate?
Answers & Comments (4)
Helpful Answer?
Yes |
No
Inappropriate?
If K > series.length/2 then reverse the criteria- like in stead of looking for 15th highest out of 20 element array - look for (20 -15 =) 5th lowest and so on....
Helpful Answer?
Yes |
No
Inappropriate?
I coded it up in C a while back: http://privatepaste.com/1f1df9d8f0
You just call select with your list, the min index, max index, and top k numbers, respectively. It can be easily changed to find the min (just reverse the swap condition)
Helpful Answer?
Yes |
No
Inappropriate?
To comment on this
question,
Sign In with Facebook or
Sign Up



0 of 0 people found this helpful
by Ajit: