add: 另一个树的子树

This commit is contained in:
2020-05-07 18:32:08 +08:00
parent 028efb9e7f
commit 431ac87901
3 changed files with 39 additions and 0 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)
})