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 think using a stack will work
- roopiitdmech March 20, 2012everytime u insert a new element to a queue, do the following
if element is less than top of the stack then push it
if it is more than top of the stack then pop the stack until a value larger than the element is reached.
reverse the stack
that's it.
example
enqueue the following one by one and observe the stack
4 6 9 3 7 2
queue
4
6 4
9 6 4
3 9 6 4
7 3 9 6 4
2 7 3 9 6 4
Stack
4
6
9
3 9
7 9
2 7 9
Reverse the stack and now do the dequeue
if a max is dequeued then pop the corresponding value from the stack
queue
2 7 3 9 6 4
2 7 3 9 6
2 7 3 9
2 7 3
2 7
2
Revered Stack
9 7 2
9 7 2
9 7 2
7 2
7 2
2
Top of the stack is the max of the queue
remember to reverse back the stack every time you enqueue an element.