feat(content): more test cases

This commit is contained in:
2025-07-13 19:25:39 +01:00
parent e28da5def2
commit 0f264ef603
94 changed files with 1840 additions and 0 deletions

View File

@@ -9,6 +9,24 @@ patterns:
- tree-traversal
- binary-search
function_signature: "def lowest_common_ancestor(root: TreeNode, p: TreeNode, q: TreeNode) -> TreeNode:"
test_cases:
visible:
- input: { root: [6, 2, 8, 0, 4, 7, 9, null, null, 3, 5], p: 2, q: 8 }
expected: 6
- input: { root: [6, 2, 8, 0, 4, 7, 9, null, null, 3, 5], p: 2, q: 4 }
expected: 2
- input: { root: [2, 1], p: 2, q: 1 }
expected: 2
hidden:
- input: { root: [6, 2, 8, 0, 4, 7, 9, null, null, 3, 5], p: 3, q: 5 }
expected: 4
- input: { root: [6, 2, 8, 0, 4, 7, 9, null, null, 3, 5], p: 7, q: 9 }
expected: 8
- input: { root: [3, 1, 4, null, 2], p: 1, q: 4 }
expected: 3
description: |
Given a binary search tree (BST), find the lowest common ancestor (LCA) node of two given nodes in the BST.