feat(content): function signatures + test cases
This commit is contained in:
@@ -10,6 +10,30 @@ patterns:
|
||||
- dfs
|
||||
- tree-traversal
|
||||
|
||||
function_signature: "def remove_leaf_nodes(root: TreeNode | None, target: int) -> TreeNode | None:"
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { root: [1, 2, 3, 2, null, 2, 4], target: 2 }
|
||||
expected: [1, null, 3, null, 4]
|
||||
- input: { root: [1, 3, 3, 3, 2], target: 3 }
|
||||
expected: [1, 3, null, null, 2]
|
||||
- input: { root: [1, 2, null, 2, null, 2], target: 2 }
|
||||
expected: [1]
|
||||
hidden:
|
||||
- input: { root: [2], target: 2 }
|
||||
expected: []
|
||||
- input: { root: [1], target: 2 }
|
||||
expected: [1]
|
||||
- input: { root: [1, 1, 1], target: 1 }
|
||||
expected: []
|
||||
- input: { root: [5, 3, 7, 2, 4, 6, 8], target: 9 }
|
||||
expected: [5, 3, 7, 2, 4, 6, 8]
|
||||
- input: { root: [1, 2, 3, 4, 2, 2, 5], target: 2 }
|
||||
expected: [1, 2, 3, 4, null, null, 5]
|
||||
- input: { root: [3, 3, 3, 3, 3, 3, 3], target: 3 }
|
||||
expected: []
|
||||
|
||||
description: |
|
||||
Given a binary tree `root` and an integer `target`, delete all the **leaf nodes** with value `target`.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user