Example #1
0
        private static void TestCombinationSum()
        {
            int[] input = new[] {2, 3, 6, 7};

            MyLeet myLeet = new MyLeet();
            List<string> results = myLeet.CombinationSum(input, 7);
            results.ForEach(i => Console.WriteLine(i));
        }
Example #2
0
        private static void TestFindAllSumPath()
        {
            TreeNode<int> root = new TreeNode<int>(3);
            root.LeftNode = new TreeNode<int>(5);
            root.RightNode = new TreeNode<int>(7);
            root.LeftNode.LeftNode = new TreeNode<int>(2);
            root.LeftNode.RightNode = new TreeNode<int>(6);
            root.LeftNode.LeftNode.LeftNode = new TreeNode<int>(4);
            root.LeftNode.LeftNode.RightNode = new TreeNode<int>(6);
            root.LeftNode.RightNode.LeftNode = new TreeNode<int>(5);
            root.RightNode.LeftNode = new TreeNode<int>(9);

            MyLeet myLeet = new MyLeet();
            //Console.WriteLine(myLeet.GetTreeDepth(root));

            //Console.WriteLine(myLeet.FindPathSum(root, 18));

            myLeet.FindAllSumPath(root, 19).ForEach(i=>Console.WriteLine(i));
        }
Example #3
0
 private static void TestLongestValidParenthese()
 {
     MyLeet myLeet = new MyLeet();
     Console.WriteLine(myLeet.LongestValidParenthese("((())"));
     Console.WriteLine(myLeet.LongestValidParenthese("(("));
     Console.WriteLine(myLeet.LongestValidParenthese("(()"));
 }
Example #4
0
 private static void TestFindMinimumWindow()
 {
     MyLeet myLeet = new MyLeet();
     Console.WriteLine(myLeet.FindMinimumWindow("adobecodebacc", "abc"));
 }
Example #5
0
        private static void TestSwapPairs()
        {
            ListNode<int> root = Utility.CreateRandomList(6);
            ListNode<int> firstNode = root;
            while (firstNode != null)
            {
                Console.Write(firstNode.Value + "->");
                firstNode = firstNode.NextNode;
            }

            Console.WriteLine();

            MyLeet myLeet = new MyLeet();
            ListNode<int> newRoot = myLeet.SwapPairs(root);

            while (newRoot != null)
            {
                Console.Write(newRoot.Value + "->");
                newRoot = newRoot.NextNode;
            }
        }
Example #6
0
 private static void TestSearchForRange()
 {
     int[] input = new int[] {8, 8, 8, 8, 8};
     MyLeet myLeet = new MyLeet();
     int l = -1, r = -1;
     myLeet.SearchForRange(input, 8, out l, out r);
     Console.WriteLine(l + " " + r);
 }
Example #7
0
 private static void TestRestoreIPAddress()
 {
     MyLeet myLeet = new MyLeet();
     List<string> results = myLeet.RestoreIPAddress("25525511135");
     if (results.Count > 0)
     {
         results.ForEach(i => Console.WriteLine(i));
     }
 }
Example #8
0
        private static void TestPermutationRecursive()
        {
            MyLeet myLeet = new MyLeet();
            List<string> results = myLeet.PermutationDFS("abcd");

            results.ForEach(i => Console.WriteLine(i.ToString()));
        }
Example #9
0
        private static void TestMyLeet()
        {
            MyLeet myleet = new MyLeet();

            TestSwapPairs();
        }