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

Sign in to watch this lesson
Advanced - Greedy and Scheduling · 3:57
A regret greedy takes the locally best move but leaves a token in a heap, so a later, better option can undo it at its marginal cost. With one share per day and unlimited holdings, a min-heap that pushes each sale's price twice (a regret token and a possible buy) finds the maximum profit. The same heap-as-budget pattern solves Furthest Building, Refueling Stops and IPO, and Huffman merging (always merge the two smallest) minimizes total merge cost.