← Questions

Lowest common ancestor with parent pointers

0
MetaCodingLast asked Feb 2026

Each tree node has a pointer to its parent, and you are given only the two nodes, not the root. Return their lowest common ancestor using O(1) extra space.

Write and test your solution herePython in your browser, the question's tests level by level, saved for you.Sign in to start coding