// 41 class MinStack { public: /** initialize your data structure here. */ int a[105], tot = 0; MinStack() { } void push(int x) { a[++tot] = x; } void pop() { tot--; } int top() { return a[tot]; } int getMin() { int ans = 1e9; for (int i = tot; i >= 1; i--) ans = (a[i] < ans) ? a[i] : ans; return ans; } }; /** * Your MinStack object will be instantiated and called as such: * MinStack obj = new MinStack(); * obj.push(x); * obj.pop(); * int param_3 = obj.top(); * int param_4 = obj.getMin(); */