You are given a binary tree where every node contains:
leftpointerrightpointerparentpointervalue
Given two nodes in this tree, return their Lowest Common Ancestor (LCA).
Below is the structure of the tree:
A
/ \
B C
/ \ / \
D E F G
/
H I
You will be given two input nodes, and your task is to return the node that is their lowest shared ancestor in the tree.
Example
Input nodes: H, E
Output: B
Explanation:
- H is under D → B → A
- E is under B → A
- Their lowest common ancestor is B.
This DoorDash VO problem asks the candidate to compute the Lowest Common Ancestor (LCA) in a binary tree with parent pointers.
Unlike traditional LCA problems where traversal starts from the root, the presence of parent pointers enables a more optimized approach.
The interviewer expects you to reason about:
- Climbing from each node toward the root
- Tracking visited ancestors
- Identifying the first intersection point
- Handling trees of uneven heights
Typical solutions include:
- Using a hash set to store ancestors of one node, then climbing from the other
- Or using a“two pointers like intersecting linked list”technique
The goal is to clearly explain how parent pointers simplify the problem and to provide the LCA efficiently.
The VOprep team has long accompanied candidates through various major company OAs and VOs, including Doordash, Google, Amazon, Citadel, SIG, providing real-time voice assistance, remote practice, and interview pacing reminders to help you stay smooth during critical moments. If you are preparing for Tiktok or similar engineering-focused companies, you can check out our customized support plans—from coding interviews to system design, we offer full guidance to help you succeed.