Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions Sample.java

This file was deleted.

31 changes: 31 additions & 0 deletions min stack problem
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
class MinStack {
Stack<Integer>st;
Stack<Integer> minst;
int min;
public MinStack() {
this.st=new Stack<>();
this.minst=new Stack<>();
this.min=Integer.MAX_VALUE;
this.minst.push(min);
}

public void push(int val) {
min=Math.min(min,val);
st.push(val);
minst.push(min);
}

public void pop() {
st.pop();
minst.pop();
min=minst.peek();
}

public int top() {
return st.peek();
}

public int getMin() {
return min;
}
}