Beispiel #1
0
        public void DistanceK_3()
        {
            var root = TestHelper.GenerateTree(new int?[] { 0, 1, null, null, 2, null, 3, null, 4 });

            var solution = new _0863_AllNodesDistanceKInBinaryTree();
            var result   = solution.DistanceK(root, root.left.right.right, 0);

            AssertHelper.AssertList(new int[] { 3 }, result);
        }
Beispiel #2
0
        public void DistanceK_1()
        {
            var root = TestHelper.GenerateTree(new int?[] { 3, 5, 1, 6, 2, 0, 8, null, null, 7, 4 });

            var solution = new _0863_AllNodesDistanceKInBinaryTree();
            var result   = solution.DistanceK(root, root.left, 2);

            AssertHelper.AssertList(new int[] { 1, 7, 4 }, result);
        }
Beispiel #3
0
        public void DistanceK_2()
        {
            var root = TestHelper.GenerateTree(new int?[] { 1 });

            var solution = new _0863_AllNodesDistanceKInBinaryTree();
            var result   = solution.DistanceK(root, root, 3);

            AssertHelper.AssertList(new int[] { }, result);
        }