コード例 #1
0
        public void IsCousinsTest()
        {
            var      s = new Solution();
            TreeNode root;

            root = TreeNode.Build(1, 2, 3, 4);
            Assert.False(s.IsCousins(root, 4, 3));

            root = TreeNode.Build(1, 2, 3, null, 4, null, 5);
            Assert.True(s.IsCousins(root, 5, 4));

            root = TreeNode.Build(1, 2, 3, null, 4);
            Assert.False(s.IsCousins(root, 2, 3));

            root = TreeNode.Build(1, 2, 3, null, null, null, 4, 5);
            Assert.False(s.IsCousins(root, 1, 2));
        }