Practice40 min
Practice: Longest Valid Windows
One-pass min tracking and the grow-and-shrink rhythm.
Three ramps up the elastic idea: Buy and Sell Stock is a one-pass scan where the "left edge" is just the minimum price seen so far, then two full grow-and-shrink windows — one where any duplicate is a violation, and one where the violation test is the window-length-minus-max-frequency budget.