Algo
Axiom
Path
Practice
Toggle theme
All Problems
Pro
Description
Solution
Submissions
Lowest Common Ancestor of a Binary Tree
IF
AlgoAxiom
Staff Engineers
JS
TS
Medium
20 mins
Given a binary tree, find the lowest common ancestor of two given nodes in the tree.
Source:
Tree Depth-First Search
pattern — AlgoAxiom
JavaScript
Test cases
Run tests
Console
Run
Submit
Test Case 1
root =
[1, 2, 3]
Test Case 2
root =
[1, 2, 3, 4, 5]
Idle
Edit test cases