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.
Taking cue from the solution about maintaining a separate stack, below is an implementation:
- aragorn August 14, 2019class StackX{
private int stackSize;
private long[] stackArray;
private int top;
private long min;
private long[] orderedStackArray;
public StackX(int stackSize){
this.stackSize = stackSize;
stackArray = new long[stackSize];
top = -1;
orderedStackArray = new long[stackSize];
}
public void push(long item){
stackArray[++top] = item;
if(min == 0.0)
min = item;
if(item < min){
orderedStackArray[top] = item;
min = item;
} else {
orderedStackArray[top] = min;
}
}
public long pop(){
return stackArray[top--];
}
public long peek(){
return stackArray[top];
}
public long peekOrderedStack(){
return orderedStackArray[top];
}
public boolean isEmpty(){
return (top == -1);
}
public boolean isFull(){
return (top == stackSize-1);
}
public long min(){
return orderedStackArray[top];
}
}
class StackApp{
public static void main(String[] args){
StackX stackX = new StackX(10);
stackX.push(40);
stackX.push(20);
stackX.push(5);
stackX.push(60);
System.out.println(stackX.min());
}
}