Why it matters
LCA is core tree query. Binary lifting is standard efficient method.
Advertisement
The architecture
Precompute up[v][k] = 2^k-th ancestor.
Query: lift deeper node up, then both together.
Advertisement
How it works end to end
Precompute: up[v][0] = parent; up[v][k] = up[up[v][k-1]][k-1].
Query: level equalize via bits of depth diff.
Then binary search.