Lowest Common Ancestor (Binary Lifting)
Medium
Binary Lifting & LCA
Given a tree rooted at node 1, answer q queries, each asking for the lowest common ancestor of two nodes. Preprocess with binary lifting so each query takes O(log n).
Constraints
1 <= n, q <= 10^5
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.