Stack Supporting Minimum Operation

easy
You have to implement stack operations push(), pop()  and getMin().
  push() function simply adds the element to the stack.
  pop() function returns the most recent element pushed into the stack, return -1 if the stack is empty.
  getMin() function returns the minimum element among the present elements in the stack.
  
  For push operation '1' is used. Eg 1 2 means push(1), 1 1 means push(1)
  For pop() operation '2' is used
  For getMin() operation '3' is used

Input Format

Inputs are handled for you

Output Format

return the desired values from the given functions.

Constraints

0 <= Q <= 100
  0 <= x <= 100

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
9
1 2 1 3 2 3 1 1 3
Output
3
2
1
Previous
Compare Two Strings After Deletions
Next
Shorten the String

Related Questions