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.
O(nlogn) Solution - Create a Min Heap O(n), Extract Minimum elements n times : n * O(logn)
- alokkumar June 21, 2016We don't need to traverse the Input Array, Once Heap is built.
Intuition : Always look for the smallest element from right. For an example, if smallest
value appears at index j then the MaxPrefix can never start from an index k>j.
Step Wise Algorithm:
1. Create a Min Heap(Containing Both Index in the input array and its value) using input array
2. Extract min element from the Heap: Lets say its index in input array was i, then ans=(n-i)
3. m=1 (Next Time, extracted minimum will be m+1th i.e. 2nd Smallest Element Over All)
4. Extract min element from the heap: It gives m+1th smallest Element Over All.
Lets say its index in input array was j, then if j>i, then j can not be a part of the solution.
However, j<i, then ans=max(ans,n-i-m) and i=j
5. m++
6. GO TO STEP 4