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

@@ -9,6 +9,30 @@ patterns:
- tree-traversal
- dfs
function_signature: "def delete_node(root: TreeNode | None, key: int) -> TreeNode | None:"
test_cases:
visible:
- input: { root: [5, 3, 6, 2, 4, null, 7], key: 3 }
expected: [5, 4, 6, 2, null, null, 7]
- input: { root: [5, 3, 6, 2, 4, null, 7], key: 0 }
expected: [5, 3, 6, 2, 4, null, 7]
- input: { root: [], key: 0 }
expected: []
hidden:
- input: { root: [5], key: 5 }
expected: []
- input: { root: [5, 3, 7], key: 5 }
expected: [7, 3]
- input: { root: [5, 3, 7, 2, 4, 6, 8], key: 3 }
expected: [5, 4, 7, 2, null, 6, 8]
- input: { root: [5, 3, 7, 2, 4, 6, 8], key: 7 }
expected: [5, 3, 8, 2, 4, 6]
- input: { root: [2, 1, 3], key: 1 }
expected: [2, null, 3]
- input: { root: [50, 30, 70, 20, 40, 60, 80], key: 50 }
expected: [60, 30, 70, 20, 40, null, 80]
description: |
Given a root node reference of a BST and a key, delete the node with the given key in the BST. Return *the **root node reference** (possibly updated) of the BST*.