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

@@ -11,6 +11,26 @@ patterns:
- bfs
- dfs
function_signature: "def distance_k(root: TreeNode, target: TreeNode, k: int) -> list[int]:"
test_cases:
visible:
- input: { root: [3, 5, 1, 6, 2, null, 8, null, null, 7, 4], target: 5, k: 2 }
expected: [7, 4, 1]
- input: { root: [1], target: 1, k: 3 }
expected: []
hidden:
- input: { root: [0, 1, null, 3, 2], target: 2, k: 1 }
expected: [1]
- input: { root: [0, 1, 2], target: 0, k: 1 }
expected: [1, 2]
- input: { root: [0, 1, 2], target: 0, k: 0 }
expected: [0]
- input: { root: [3, 5, 1, 6, 2, 0, 8, null, null, 7, 4], target: 3, k: 1 }
expected: [5, 1]
- input: { root: [1, 2, 3, 4], target: 4, k: 2 }
expected: [1]
description: |
Given the `root` of a binary tree, the value of a target node `target`, and an integer `k`, return *an array of the values of all nodes that have a distance* `k` *from the target node*.