feat(content): function signatures + test cases

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

View File

@@ -9,6 +9,24 @@ patterns:
- dfs
- tree-traversal
function_signature: "def bst_to_gst(root: TreeNode) -> TreeNode:"
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: [1] }
expected: [1]
- input: { root: [2, 1, 3] }
expected: [5, 6, 3]
- input: { root: [3, 2, 4, 1] }
expected: [7, 9, 4, 10]
- input: { root: [5, 3, 7, 2, 4, 6, 8] }
expected: [26, 33, 15, 35, 30, 21, 8]
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.