Longest price rally
A price dashboard highlights the longest rally: the longest stretch of consecutive days where each day's price is strictly higher than the previous day's. Given the daily prices in order, return the length of that stretch. A single day counts as a stretch of length 1; an empty history returns 0. Example: [1, 2, 3, 1, 4, 5, 6, 7] returns 5 (the run 1, 4, 5, 6, 7).
Implement
longest_rally(prices: list[int]) → intExamples
in
[[1,2,3,1,4,5,6,7]]out5What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 13 min
solution.py
InputExpectedGot
[[1,2,3,1,4,5,6,7]]5not run yetsample