add: 二叉树的最近公共祖先

This commit is contained in:
2020-05-10 15:31:25 +08:00
12 changed files with 223 additions and 2 deletions

View File

@ -0,0 +1,7 @@
import { isSubtree } from '../../src/tree/subtree-of-another-tree'
import Tree from './Tree'
test('另一个树的子树', () => {
expect(isSubtree(Tree.arrToTree([3, 4, 5, 1, 2]), Tree.arrToTree([4, 1, 2]))).toBe(true)
expect(isSubtree(Tree.arrToTree([3, 4, 5, 1, 2, null, null, null, null, 0]), Tree.arrToTree([4, 1, 2]))).toBe(false)
})