feat(content): function signatures + test cases

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

View File

@@ -9,6 +9,28 @@ patterns:
- dfs
- tree-traversal
function_signature: "def convert_bst(root: TreeNode | None) -> TreeNode | None:"
test_cases:
visible:
- input: { root: [4, 1, 6, 0, 2, 5, 7, null, null, null, 3, null, null, null, 8] }
expected: [30, 36, 21, 36, 35, 26, 15, null, null, null, 33, null, null, null, 8]
- input: { root: [0, null, 1] }
expected: [1, null, 1]
hidden:
- input: { root: [] }
expected: []
- input: { root: [5] }
expected: [5]
- input: { root: [2, 1, 3] }
expected: [5, 6, 3]
- input: { root: [5, 3, 8, 1, 4, 6, 9] }
expected: [33, 37, 17, 38, 34, 23, 9]
- input: { root: [1, null, 2, null, 3, null, 4] }
expected: [10, null, 9, null, 7, null, 4]
- input: { root: [-3, -4, -2] }
expected: [-5, -9, -2]
description: |
Given the `root` of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus the sum of all keys greater than the original key in BST.