Problem context and objectives
Mission briefing
Archive pathfinder · Clues branch through a living archive
Explore only the branches that can still contain the answer: The Shared Ancestor.
Ignoring the parent-child rule turns a focused search into a full maze traversal.
How you win
- 1Recognize when Lowest common ancestor in binary tree matches the clues
- 2Keep this true after every move: search(node) returns the lowest node in that subtree containing p, q, or both
- 3Reach the result within O(n) time and O(height) space
Rules and pressure
- Target cost: O(n) time and O(height) space
- State rule: search(node) returns the lowest node in that subtree containing p, q, or both
Lesson 1 of 3
Track evidence returned from targets 5 and 1; their first two-sided meeting is the lowest ancestor.
Watch two target signals rise from different branches.
Your call · Node 3 receives 5 from the left and 1 from the right. What should it return?