예제 #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());
        }