Code Room
CodingMediumcod-g1198
Subject ArraysLevel Entry–Mid~13 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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]) → int
Examples
in[[1,2,3,1,4,5,6,7]]out5
What 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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.