feat(content): function signatures + test cases

This commit is contained in:
2025-07-13 19:53:34 +01:00
parent 9e6c6d256f
commit 65a8d525f5
203 changed files with 4526 additions and 0 deletions

View File

@@ -10,6 +10,24 @@ patterns:
- bfs
- tree-traversal
function_signature: "def average_of_levels(root: TreeNode) -> list[float]:"
test_cases:
visible:
- input: { root: [3, 9, 20, null, null, 15, 7] }
expected: [3.0, 14.5, 11.0]
- input: { root: [3, 9, 20, 15, 7] }
expected: [3.0, 14.5, 11.0]
hidden:
- input: { root: [1] }
expected: [1.0]
- input: { root: [1, 2, 3, 4, 5, 6, 7] }
expected: [1.0, 2.5, 5.5]
- input: { root: [1, 2, null, 3, null, 4] }
expected: [1.0, 2.0, 3.0, 4.0]
- input: { root: [0, -1, 1] }
expected: [0.0, 0.0]
description: |
Given the `root` of a binary tree, return *the average value of the nodes on each level in the form of an array*.