feat(content): function signatures + test cases

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

View File

@@ -8,6 +8,28 @@ categories:
patterns:
- tree-traversal
function_signature: "def insert_into_bst(root: TreeNode, val: int) -> TreeNode:"
test_cases:
visible:
- input: { root: [4, 2, 7, 1, 3], val: 5 }
expected: [4, 2, 7, 1, 3, 5]
- input: { root: [40, 20, 60, 10, 30, 50, 70], val: 25 }
expected: [40, 20, 60, 10, 30, 50, 70, null, null, 25]
hidden:
- input: { root: [], val: 5 }
expected: [5]
- input: { root: [1], val: 2 }
expected: [1, null, 2]
- input: { root: [2], val: 1 }
expected: [2, 1]
- input: { root: [5, 3, 7], val: 2 }
expected: [5, 3, 7, 2]
- input: { root: [5, 3, 7], val: 8 }
expected: [5, 3, 7, null, null, null, 8]
- input: { root: [10, 5, 15, 3, 7], val: 6 }
expected: [10, 5, 15, 3, 7, null, null, null, null, 6]
description: |
You are given the `root` node of a binary search tree (BST) and a `val` to insert into the tree. Return *the root node of the BST after the insertion*. It is **guaranteed** that the new value does not exist in the original BST.