Rar the Cat has developed a new data structure, the MinStack!
Rar's data structure supports the following operations:
There will be a total of Q queries to the data structure. Help Rar implement it.
This is a function-call question. You are to implement the following functions:
It is guaranteed that pop, top and getMin will not be called when the stack is empty.
You may access the sample grader and solution template from the Attachments tab to test your solutions.
Subtask 1 (15%): 1 ≤ Q ≤ 103, 1 ≤ X ≤ 109.
Subtask 2 (23%): 1 ≤ Q ≤ 105, 1 ≤ X ≤ 109.
Subtask 3 (17%): 1 ≤ Q ≤ 3 * 106, 1 ≤ X ≤ 2.
Subtask 4 (10%): 1 ≤ Q ≤ 3 * 106, 1 ≤ X ≤ 109. pop will never be called.
Subtask 5 (35%): 1 ≤ Q ≤ 3 * 106, 1 ≤ X ≤ 109.
Subtask 6 (0%): Sample Testcases
6 0 5 0 9 2 3 0 1 3
9 5 1
7 0 3 0 1 3 2 1 0 5 3
1 1 3
Subtask | Score |
---|---|
1 | 15 |
2 | 23 |
3 | 17 |
4 | 10 |
5 | 35 |
6 | 0 |