Problems > Lowest Common Ancestor > Editorial

Lowest Common Ancestor — Solution & Editorial

Back to the Problem

At these limits the walk-up method works: lift the deeper node to equal depth, then lift both together until they meet. (Binary lifting handles bigger limits.)

Complexity: O(Q · depth)