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

Sign in to watch this lesson
Algorithms - Arrays · 5:04
The best run of consecutive days in a PnL series, found in one pass. We draw the prefix sums of [-2, 1, -3, 4, -1, 2, 1, -5, 4] as a line, track its lowest point so far and read the answer, 6, as the biggest rise; then run Kadane's algorithm, watch its running sum reset twice, and see why it is the same idea in disguise, measured against checking every segment. We finish with the traps (all-negative arrays, overflow, circular sessions, best trade) and the maximum average over runs of at least L days via binary search on the answer.