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

Sign in to watch this lesson
Algorithms - Dynamic Programming · 4:40
Given a sequence of prices, find the longest subsequence that rises strictly. We start with the natural O(n^2) DP over the best length ending at each position, whose back-arrows trace both answers of the example, then switch to the tails array, which stays sorted so lower_bound updates exactly one slot per price in O(log n). The tails are not the answer, so we restore a real subsequence from the slot each price landed in, and measure both methods on this Mac.