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

Sign in to watch this lesson
Algorithms - Greedy · 4:00
Most greedy algorithms start by sorting and then sweep once, proved by an invariant that keeps greedy ahead. We find the smallest amount coins [1, 2, 2, 7, 9] can't pay by growing a reach of payable amounts (1, 3, 5, then a gap at 6), pair Ferris-wheel riders [2, 3, 7, 8] lightest-with-heaviest into two gondolas, and hand out tickets from a std::multiset with prev(upper_bound(x)), erasing by iterator because erase by value removes every copy.