Пример #1
0
        public void FindsALowerCommonAncestor()
        {
            var inputOne  = TreeNode.BuildTreeOne();
            var hasSumOne = PathSum.HasPath(inputOne, 9);

            Assert.True(hasSumOne);

            var inputTwo  = TreeNode.BuildTreeThree();
            var hasSumTwo = PathSum.HasPath(inputTwo, 4);

            Assert.True(hasSumTwo);
        }
Пример #2
0
        public void ReturnsLowestCommonAncestorForInheritedNodes()
        {
            var inputOne  = TreeNode.BuildTreeOne();
            var hasSumOne = PathSum.HasPath(inputOne, 8);

            Assert.False(hasSumOne);

            var inputTwo  = TreeNode.BuildTreeThree();
            var hasSumTwo = PathSum.HasPath(inputTwo, 18);

            Assert.False(hasSumTwo);
        }