@bittu :
In your first approach which u pointed out :
What if the minimum element is poped out of the stack ?? We may have
to search the whole stack to get the minimum element. O(n) in
worst case
In your second approach which u pointed out :
If u use 2 stacks, consistency of 2 stacks in
@juver++ correct
@ankit you can see here
1st Approach .
You can implement this by having each node in the stack keep track of
the minimum beneath itself. Then, to find the min, you just look at
what the top element thinks is the min.When you push an element onto
the stack, the element is given