feat(content): more test cases

This commit is contained in:
2025-07-13 19:25:39 +01:00
parent 98ebb1600f
commit 16b02451d0
94 changed files with 1840 additions and 0 deletions

View File

@@ -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.