示例#1
0
        public void TestFirstCase()
        {
            TreeNode tree   = null;
            var      sol    = new MinDepth(tree);
            var      result = sol.GetMinDepth();

            Assert.AreEqual(0, result);
        }
示例#2
0
        public void TestThirdCase()
        {
            var tree   = new TreeNode(3, new TreeNode(9), new TreeNode(20, new TreeNode(15), new TreeNode(7)));
            var sol    = new MinDepth(tree);
            var result = sol.GetMinDepth();

            Assert.AreEqual(2, result);
        }
示例#3
0
        public void TestFourthCase()
        {
            var tree   = new TreeNode(1, new TreeNode(2));
            var sol    = new MinDepth(tree);
            var result = sol.GetMinDepth();

            Assert.AreEqual(2, result);
        }
示例#4
0
        public void TestSecondCase()
        {
            TreeNode tree   = new TreeNode(3);
            var      sol    = new MinDepth(tree);
            var      result = sol.GetMinDepth();

            Assert.AreEqual(1, result);
        }
示例#5
0
        public int MinDepth(TreeNode root)
        {
            var sol = new MinDepth(root);

            return(sol.GetMinDepth());
        }