Longest window where prices stay within a band
Find the longest contiguous window of prices whose range (max minus min inside the window) is at most a given limit, a stylized "how long did price stay in a tight band" query.
prices = [1, 5, 3, 4, 8], limit = 3
-> 3 # the window [5, 3, 4] has range 5 - 3 = 2
Return the length of the longest window with (max - min) <= limit, in O(n) time.
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.