feat(content): function signatures + test cases
This commit is contained in:
@@ -10,6 +10,28 @@ patterns:
|
||||
- bfs
|
||||
- tree-traversal
|
||||
|
||||
function_signature: "def zigzag_level_order(root: TreeNode) -> list[list[int]]:"
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { root: [3, 9, 20, null, null, 15, 7] }
|
||||
expected: [[3], [20, 9], [15, 7]]
|
||||
- input: { root: [1] }
|
||||
expected: [[1]]
|
||||
- input: { root: [] }
|
||||
expected: []
|
||||
hidden:
|
||||
- input: { root: [1, 2, 3, 4, 5, 6, 7] }
|
||||
expected: [[1], [3, 2], [4, 5, 6, 7]]
|
||||
- input: { root: [1, 2, null, 3, null, 4] }
|
||||
expected: [[1], [2], [3], [4]]
|
||||
- input: { root: [1, 2, 3, 4, null, null, 5] }
|
||||
expected: [[1], [3, 2], [4, 5]]
|
||||
- input: { root: [0, -1, 100, -50, 50, -100, 200] }
|
||||
expected: [[0], [100, -1], [-50, 50, -100, 200]]
|
||||
- input: { root: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15] }
|
||||
expected: [[1], [3, 2], [4, 5, 6, 7], [15, 14, 13, 12, 11, 10, 9, 8]]
|
||||
|
||||
description: |
|
||||
Given the `root` of a binary tree, return *the zigzag level order traversal of its nodes' values* (i.e., from left to right, then right to left for the next level and alternate between).
|
||||
|
||||
|
||||
Reference in New Issue
Block a user