is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.
CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.
Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.
Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.
I guess we can use a min heap of size 100 and get an O(n) algo.
- bhat.vi June 24, 2008The algo can be as follows.
Let the array be stored in A[1..n]
1) Take the first 100 elements from the given array and build a heap. --> O(100)
Note : The heap can be created inplace i.e. on elements A[1] to A[100]
2) for(i = 101 to n) do
curr = A[i];
2.1) compare the curr element with the minimun element of the heap.
2.1.1) if (curr > minHeap) //Note : minHeap = A[1].
then
exchange the curr element with minHeap. --> O(1)
reheapify the resultant heap (of size 100). --> (O(ln(100)))
2.2) i = i + 1;
done
So overall complexity of this algo is
n*O(ln(100)){reheapify} + O(100){build heap} + O(n) {exchange minHeap with curr}
= O(n).