public void PathSumTest()
 {
     //    2
     //  /  \
     // 1   3
     //     /\
     //    2 4
     TreeNode    root  = buildTreeTest(new object[] { 10, 5, -3, 3, 2, null, 11, 3, -2, null, 1 });//new object[] { 10, 5, -3, 3, 2, null, 11, 3, -2, null, 1 }
     TreePathSum modes = new TreePathSum();
     int         ints  = modes.PathSum(root, 8);
 }
    public void GetPathSumFromBottomByStack_Ok(int n)
    {
        var root = TreeUtil.BuildTreeLikeA(n);

        Assert.NotNull(root);
        Assert.Equal(1, root.Val);

        var sums       = TreePathSum.GetPathSumFromBottomByStack(root);
        var onePathSum = 2 * n + 1;

        Assert.Equal(4, sums.Count);
        Assert.Equal(onePathSum, sums[0]);
    }
        static void Main(string[] args)
        {
            Console.WriteLine("Binary Search: Bitonic Array Maximum");
            Console.WriteLine(FindMax(new int[] { 1, 3, 8, 12, 4, 2 }));
            Console.WriteLine(FindMax(new int[] { 3, 8, 3, 1 }));
            Console.WriteLine(FindMax(new int[] { 1, 3, 8, 12 }));
            Console.WriteLine(FindMax(new int[] { 10, 9, 8 }));

            Console.WriteLine("\nTwo Pointers: Pair with Target Sum");
            int[] result = Search(new int[] { 1, 2, 3, 4, 6 }, 6);
            Console.WriteLine("Pair with target sum: [" + result[0] + ", " + result[1] + "]");
            result = Search(new int[] { 2, 5, 9, 11 }, 11);
            Console.WriteLine("Pair with target sum: [" + result[0] + ", " + result[1] + "]");

            Console.WriteLine("\n‘K’ Closest Points to the Origin");
            Point[]      points  = new Point[] { new Point(1, 3), new Point(3, 4), new Point(2, -1), new Point(1, -1), new Point(-1, -1) };
            List <Point> result2 = FindClosestPoints(points, 2);

            Console.WriteLine("Here are the k points closest the origin: ");
            foreach (Point p in result2)
            {
                Console.WriteLine("[" + p.x + " , " + p.y + "] ");
            }

            Console.WriteLine("\n‘K’ Closest Points to the Origin(0,0)");
            Point result3 = ClosestToOrigin(points, 2);

            Console.WriteLine("[" + result3.x + " , " + result3.y + "] ");

            Console.WriteLine("\n Subsets");
            List <List <int> > result4 = Subsets.FindSubsets(new int[] { 1, 3 });

            Console.WriteLine("Here is the list of subsets: " + Subsets.ToString(result4));
            result4 = Subsets.FindSubsets(new int[] { 1, 5, 3 });
            Console.WriteLine("Here is the list of subsets: " + Subsets.ToString(result4));

            Console.WriteLine("\n Binary Tree Path Sum");
            TreeNode root = new TreeNode(12);

            root.left        = new TreeNode(7);
            root.right       = new TreeNode(1);
            root.left.left   = new TreeNode(9);
            root.right.left  = new TreeNode(10);
            root.right.right = new TreeNode(5);
            Console.WriteLine("Tree has path: " + TreePathSum.hasPath(root, 23));
            Console.WriteLine("Tree has path: " + TreePathSum.hasPath(root, 16));


            Console.ReadKey();
        }