feat(content): function signatures + test cases
This commit is contained in:
@@ -11,6 +11,26 @@ patterns:
|
||||
- tree-traversal
|
||||
- dfs
|
||||
|
||||
function_signature: "def preorder_traversal(root: TreeNode) -> list[int]:"
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { root: [1, null, 2, 3] }
|
||||
expected: [1, 2, 3]
|
||||
- input: { root: [] }
|
||||
expected: []
|
||||
- input: { root: [1] }
|
||||
expected: [1]
|
||||
hidden:
|
||||
- input: { root: [1, 2, 3, 4, 5, null, 8, null, null, 6, 7, 9] }
|
||||
expected: [1, 2, 4, 5, 6, 7, 3, 8, 9]
|
||||
- input: { root: [1, 2, null, 3, null, 4] }
|
||||
expected: [1, 2, 3, 4]
|
||||
- input: { root: [1, null, 2, null, 3, null, 4] }
|
||||
expected: [1, 2, 3, 4]
|
||||
- input: { root: [5, 3, 7, 2, 4, 6, 8] }
|
||||
expected: [5, 3, 2, 4, 7, 6, 8]
|
||||
|
||||
description: |
|
||||
Given the `root` of a binary tree, return *the preorder traversal of its nodes' values*.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user