feat(content): function signatures + test cases
This commit is contained in:
@@ -9,6 +9,26 @@ patterns:
|
||||
- tree-traversal
|
||||
- dfs
|
||||
|
||||
function_signature: "def balance_bst(root: TreeNode) -> TreeNode:"
|
||||
|
||||
test_cases:
|
||||
visible:
|
||||
- input: { root: [1, null, 2, null, 3, null, 4] }
|
||||
expected: [2, 1, 3, null, null, null, 4]
|
||||
- input: { root: [2, 1, 3] }
|
||||
expected: [2, 1, 3]
|
||||
hidden:
|
||||
- input: { root: [1] }
|
||||
expected: [1]
|
||||
- input: { root: [1, null, 2] }
|
||||
expected: [1, null, 2]
|
||||
- input: { root: [3, 2, null, 1] }
|
||||
expected: [2, 1, 3]
|
||||
- input: { root: [1, null, 2, null, 3, null, 4, null, 5] }
|
||||
expected: [3, 1, 4, null, 2, null, 5]
|
||||
- input: { root: [5, 4, null, 3, null, 2, null, 1] }
|
||||
expected: [3, 1, 4, null, 2, null, 5]
|
||||
|
||||
description: |
|
||||
Given the `root` of a binary search tree, return *a **balanced** binary search tree with the same node values*. If there is more than one answer, return **any of them**.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user