feat(content): function signatures + test cases

This commit is contained in:
2025-07-13 19:53:34 +01:00
parent b434eb3a49
commit a7d29b7cce
203 changed files with 4526 additions and 0 deletions

View File

@@ -10,6 +10,30 @@ patterns:
- dfs
- tree-traversal
function_signature: "def prune_tree(root: TreeNode) -> TreeNode:"
test_cases:
visible:
- input: { root: [1, null, 0, 0, 1] }
expected: [1, null, 0, null, 1]
- input: { root: [1, 0, 1, 0, 0, 0, 1] }
expected: [1, null, 1, null, 1]
- input: { root: [1, 1, 0, 1, 1, 0, 1, 0] }
expected: [1, 1, 0, 1, 1, null, 1]
hidden:
- input: { root: [1] }
expected: [1]
- input: { root: [0] }
expected: null
- input: { root: [0, 0, 0] }
expected: null
- input: { root: [1, 1, 1, 1, 1, 1, 1] }
expected: [1, 1, 1, 1, 1, 1, 1]
- input: { root: [0, 0, 0, 1] }
expected: [0, 0, null, 1]
- input: { root: [1, 0, 0, 0, 0, 0, 1] }
expected: [1, null, 0, null, 1]
description: |
Given the `root` of a binary tree, return *the same tree where every subtree (of the given tree) not containing a* `1` *has been removed*.