feat(content): more test cases
This commit is contained in:
@@ -10,6 +10,24 @@ patterns:
|
||||
- dfs
|
||||
- tree-traversal
|
||||
|
||||
function_signature: "def is_subtree(root: TreeNode | None, sub_root: TreeNode | None) -> bool:"
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { root: [3, 4, 5, 1, 2], sub_root: [4, 1, 2] }
|
||||
expected: true
|
||||
- input: { root: [3, 4, 5, 1, 2, null, null, null, null, 0], sub_root: [4, 1, 2] }
|
||||
expected: false
|
||||
- input: { root: [1, 1], sub_root: [1] }
|
||||
expected: true
|
||||
hidden:
|
||||
- input: { root: [1], sub_root: [1] }
|
||||
expected: true
|
||||
- input: { root: [1, 2, 3], sub_root: [2] }
|
||||
expected: true
|
||||
- input: { root: [1, 2, 3], sub_root: [3, 1] }
|
||||
expected: false
|
||||
|
||||
description: |
|
||||
Given the roots of two binary trees `root` and `subRoot`, return `true` if there is a subtree of `root` with the same structure and node values of `subRoot` and `false` otherwise.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user