public void Test() { MinStack minStack = new MinStack(); minStack.Push(-2); minStack.Push(0); minStack.Push(-3); Console.WriteLine(minStack.GetMin()); minStack.Pop(); minStack.Top(); Console.WriteLine(minStack.GetMin()); }
public void MinStackTest() { var minStack = new MinStack(); minStack.Push(-2); minStack.Push(0); minStack.Push(-3); Assert.Equal(-3, minStack.GetMin()); minStack.Pop(); Assert.Equal(0, minStack.Top()); Assert.Equal(-2, minStack.GetMin()); }
public void Test() { MinStack minStack = new MinStack(); minStack.Push(-2); minStack.Push(0); minStack.Push(-3); var c = minStack.Min(); minStack.Pop(); var a = minStack.Top(); var b = minStack.Min(); }
//static async Task<string> SaySomething() //{ // await Task.Delay(5); // result = "Hello world!"; // return "Something"; //} static void EasyQuestionDriver() { var solu = new Solution(); var headP = new ListNode(1); headP.next = new ListNode(2); //headP.next.next = new ListNode(2); //headP.next.next.next = new ListNode(1); var revnum = solu.Reverse(-2147483648); var revnum1 = solu.Reverse(-5); var head = new ListNode(1) { next = new ListNode(2) { next = new ListNode(3) } }; solu.ReverseList(head); solu.MajorityElement(new int[] { 5, 6, 6 }); var headA = new ListNode(4); headA.next = new ListNode(1); var node8 = new ListNode(8); headA.next.next = node8; var headB = new ListNode(5); headB.next = new ListNode(0); headB.next.next = new ListNode(1); headB.next.next.next = node8; var solul = new Solution(); var result = solul.GetIntersectionNode(headA, headB); var minStack = new MinStack(); minStack.Push(-2); minStack.Push(0); minStack.Push(-3); minStack.GetMin(); // return -3 minStack.Pop(); minStack.Top(); // return 0 minStack.GetMin(); // return -2 var root = solu.CreateTreeInput(); var profit = solu.MaxProfit(new int[] { 2, 4, 1 }); var depth = solu.MaxDepth(root); var isSymmetric = solu.IsSymmetric(root); }
static void Main(string[] args) { MinStack minStack = new MinStack(); minStack.Push(-2); minStack.Push(0); minStack.Push(-3); var x = minStack.GetMin(); minStack.Pop(); var y = minStack.Top(); var z = minStack.GetMin(); Console.WriteLine($" Answer: {x}, {y}, {z}"); }
public void Test1() { // Arrange var minStack = new MinStack(); minStack.Push(-2); minStack.Push(0); minStack.Push(-3); // Act // Assert Assert.AreEqual(-3, minStack.GetMin()); minStack.Pop(); Assert.AreEqual(0, minStack.Top()); Assert.AreEqual(-2, minStack.GetMin()); minStack.Pop(); Assert.AreEqual(-2, minStack.GetMin()); minStack.Pop(); minStack.Push(1); Assert.AreEqual(1, minStack.GetMin()); }
private static void Main() { // "2[z]2[2[y]pq1[2[jk]e1[f]]]ef" var decoded = DecodeString("2[z]2[2[y]pq1[2[jk]e1[f]]]ef"); var node = new UndirectedGraphNode(0); node.neighbors = new List <UndirectedGraphNode> { node, node }; var clone = CloneGraph(node); var postfix = EvalRPN(new string[] { "10", "6", "9", "3", "+", "-11", "*", "/", "*", "17", "+", "5", "+" }); var temperatures = new int[] { 73, 74, 75, 71, 69, 72, 76, 73 }; var result = DailyTemperatures(temperatures); var mStack = new MinStack(); mStack.Push(2147483646); mStack.Push(2147483646); mStack.Push(2147483647); var top = mStack.Top(); mStack.Pop(); var getMin = mStack.GetMin(); mStack.Pop(); getMin = mStack.GetMin(); mStack.Pop(); mStack.Push(2147483647); top = mStack.Top(); getMin = mStack.GetMin(); mStack.Push(-2147483648); top = mStack.Top(); getMin = mStack.GetMin(); mStack.Pop(); getMin = mStack.GetMin(); }