Пример #1
0
        public void Min_Test()
        {
            var stack = new StackWithMin();

            stack.Push(3);
            stack.Push(2);
            stack.Push(8);
            stack.Push(1);

            Assert.AreEqual(1, stack.Min());
        }
Пример #2
0
        static void Main(string[] args)
        {
            StackWithMin stack = new StackWithMin();
            stack.push(5);
            stack.push(6);
            stack.push(3);
            stack.push(7);
            Console.WriteLine(stack.Min());
            stack.pop();
            stack.pop();
            Console.WriteLine(stack.Min());

            StackWithMin2 stack2 = new StackWithMin2();
            stack2.push(5);
            stack2.push(6);
            stack2.push(3);
            stack2.push(7);
            Console.WriteLine(stack2.Min());
            stack2.pop();
            stack2.pop();
            Console.WriteLine(stack2.Min());
        }
Пример #3
0
        public void Run()
        {
            StackWithMin  stack  = new StackWithMin();
            StackWithMin2 stack2 = new StackWithMin2();

            for (int i = 1; i <= 10; i++)
            {
                int value = AssortedMethods.RandomIntInRange(0, 100);
                stack.Push2(value);
                stack2.Push2(value);
                Console.Write(value + ", ");
            }
            Console.WriteLine('\n');
            for (int i = 1; i <= 10; i++)
            {
                Console.WriteLine("Popped " + stack.Pop().Value + ", " + stack2.Pop2());
                Console.WriteLine("New min is " + stack.Min() + ", " + stack2.Min());
            }
        }
        static void Main(string[] args)
        {
            //LINQSample ls = new LINQSample();
            //ls.QueryUsingEnumerable();
            //Console.WriteLine("\n\n");
            //ls.QueryUsingVar();
            //Console.WriteLine("\n\n");
            //ls.QueryModification();
            //Console.WriteLine("\n\n");
            //ls.QueryUsingLetKeyword();

            //GroupAnagrams ga = new GroupAnagrams();
            //Dictionary<string, int> map = new Dictionary<string, int>();
            //map.Add("bat", 1);
            //map.Add("rat", 2);
            //map.Add("tab", 3);
            //map.Add("tar", 4);
            //map.Add("art", 5);
            //ga.Group(map);

            //int[] arr = new int[]{4, 5, 2, 2, 0, -1, 25, 20, 11, 13, 21, 3};
            //NextLarger nl = new NextLarger();
            //nl.FindNext(arr);

            //StringCruncher sc = new StringCruncher();
            //char[] arr = sc.Crunch("AAABBCDEE");

            //int[] arr = new int[] { 6, 8, 9, 1, 4, 5 };
            //FindMinSortedArray fa = new FindMinSortedArray();
            //int min = fa.FindMin(arr);

            //SearchInSortedArray s = new SearchInSortedArray();
            //int index = s.Search(arr, 1);

            //strStr ss = new strStr();
            //bool val = ss.IsSubString("DUMBELL", "DUMB");

            //int[] arr = new int[]{1,2,2,3,4,4,5,5,6,6,6,7,8,9};
            //RemoveDupFromSorted dup = new RemoveDupFromSorted();
            //dup.Remove(arr);

            //int[] arr = new int[] { 2,2, 9};
            //EvenOdd eo = new EvenOdd();
            //int index = eo.FindIndex(arr);

            //MulnDiv md = new MulnDiv();
            //int data = md.PerformDivision(100, 55);
            //Console.WriteLine(data);

            //int mul = md.PerformMultiplication(3, 180000);
            //Console.WriteLine(mul);

            //SqureRoot sr = new SqureRoot();
            //int num = sr.FindSquareRoot(81);
            //Console.WriteLine(num);

            //FindMaxSubArraySum f = new FindMaxSubArraySum();
            //int[] arr = new int[] {5,7,8,10,-5,-2,6,15,31 };
            //int sum = f.FindMaxSum(arr);

            //MoveAllZerosToBeginning m = new MoveAllZerosToBeginning();
            //int[] arr = new int[] {5,7,8,0,0,6,15,31 };

            //int[] res = m.Move(arr);

            StackWithMin sMin = new StackWithMin();
            sMin.Push(5);
            sMin.Push(15);
            sMin.Push(3);
            sMin.Push(2);
            sMin.Push(1);

            int min = sMin.Min();
        }
Пример #5
0
 public int Min()
 {
     return(Math.Min(_in.Min(), _out.Min()));
 }