static void Main(string[] args) { MinStack stack = new MinStack(); stack.Push(2); stack.Push(0); stack.Push(3); stack.Push(0); Console.WriteLine(stack.GetMin()); stack.Pop(); Console.WriteLine(stack.GetMin()); stack.Pop(); Console.WriteLine(stack.GetMin()); stack.Pop(); Console.WriteLine(stack.GetMin()); Console.ReadLine(); }
private static void Run() { var minStack = new MinStack(); minStack.Push(-2); minStack.Push(0); minStack.Push(-3); minStack.GetMin(); // Returns -3. minStack.Pop(); minStack.Top(); // Returns 0. minStack.GetMin(); // Returns -2. }
static void Test() { MinStack minStack = new MinStack(); minStack.Push(-2); minStack.Push(0); minStack.Push(-3); var m1 = minStack.GetMin(); //--> 返回 - 3. Console.WriteLine(m1); minStack.Pop(); var t = minStack.Top(); //--> 返回 0. Console.WriteLine(t); var m2 = minStack.GetMin(); //--> 返回 - 2. Console.WriteLine(m2); }
static void Main(string[] args) { /* * 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(); */ MinStack minStack = new MinStack(); minStack.Push(-2); minStack.Push(0); minStack.Push(-3); minStack.GetMin(); minStack.Pop(); minStack.Top(); minStack.GetMin(); }