ā” Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 18m 48s17 days 22 hours 18 minutes 48 seconds.
ā” Build the skills to land top-paying quant jobs. Offer ends in 17d 22h 18m 48s17 days 22 hours 18 minutes 48 seconds.

Sign in to watch this lesson
Advanced - Trees Ā· 4:28
A depth-first search that writes a vertex on entry and again after each child returns produces an Euler tour of 2n - 1 entries. The lowest common ancestor of u and v is the shallowest entry between their first appearances, so LCA becomes a range-minimum query over heights. A sparse table answers it with two overlapping power-of-two blocks in O(1) after O(n log n) preprocessing, which on this Mac answered 10^7 queries in about a third of a second.