##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
You've learned binary lifting. Now find the lowest common ancestor of two nodes efficiently.
Finding ancestors fast
(Nearest shared ancestor)
(Distance and path queries)
(Climb to same depth)
(Climbing step by step)
(Jump in powers of two)
(Building the up table)
(Finding the split point)
(Find the meeting point)
(Preprocessing and query time)
(LeetCode 236)
(LeetCode 236)
(enabling array algorithms)
(Null and target nodes)
Combine left and right results
(Pseudocode)
(LeetCode 236)
(Tracing the recursion)
(Bottom-up propagation)
(Convert tree to array)
(DFS with recording)
(Minimum depth in range)
(Precompute range minimums)
(Dynamic programming)
(Overlapping ranges trick)
(Combining both techniques)
(Time and space analysis)
(Using LCA)
(CSES 1135)
(CSES 1135)
(Setup for fast queries)
(Pseudocode)
(CSES 1135)
(Pay once, query many)
(CSES 1136)
(CSES 1136)
Add to endpoints, subtract ...
(Sum children contributions)
(Mark and propagate)
(Pseudocode)
(CSES 1136)
(Tracing the algorithm)
(Fixing the formula)
(Efficient path updates)
(Maximum, minimum, sum)
(Carrying extra data)
Knowledge check
(When to use each)
(Pitfalls to avoid)
(Beyond basic LCA)
(What you learned)