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

@@ -12,6 +12,24 @@ patterns:
- dfs
- tree-traversal
function_signature: "def add_one_row(root: TreeNode, val: int, depth: int) -> TreeNode:"
test_cases:
visible:
- input: { root: [4, 2, 6, 3, 1, 5], val: 1, depth: 2 }
expected: [4, 1, 1, 2, null, null, 6, 3, 1, 5]
- input: { root: [4, 2, null, 3, 1], val: 1, depth: 3 }
expected: [4, 2, null, 1, 1, 3, null, null, 1]
hidden:
- input: { root: [1], val: 2, depth: 1 }
expected: [2, 1]
- input: { root: [1, 2, 3], val: 5, depth: 2 }
expected: [1, 5, 5, 2, null, null, 3]
- input: { root: [1], val: 2, depth: 2 }
expected: [1, 2, 2]
- input: { root: [4, 2, 6, 3, 1, 5], val: 1, depth: 1 }
expected: [1, 4, null, 2, 6, 3, 1, 5]
description: |
Given the `root` of a binary tree and two integers `val` and `depth`, add a row of nodes with value `val` at the given depth `depth`.