Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 45s1 days 16 hours 1 minutes 45 seconds.
Price your future right. 60% off with code BLACKSCHOLES at USD checkout. Offer ends in 1d 16h 01m 45s1 days 16 hours 1 minutes 45 seconds.

Sign in to watch this lesson
Advanced - Data Structures and Range Queries · 5:05
Union-find only ever merges, and that one-way merging solves more than connectivity. Replaying interval assignments last to first with parent[v] = v + 1 paints every cell once; storing a parity (or a distance) on each link turns it into an online two-colouring with the link rule x ^ y ^ 1; Arpa's sweep with a monotonic stack answers range minimums offline as a[find(L)]; and pouring smaller sets into larger ones bounds every element to log n moves.