Ctrl K

Longest Rising Streak

Easy
The array prices holds a stock's price day by day. A rising streak is a run of **consecutive** days where the price is strictly higher each day than the day before. A single day on its own is also a streak of length 1. Return the length of the longest rising streak.
Example 1
prices=[5, 8, 2, 4, 6, 9, 9, 10] → 4

The longest unbroken rise is [2, 4, 6, 9], four days. Then 9 → 9: the price did not go up, so the rise ends.

Example 2
prices=[3, 3, 3] → 1

The price never strictly rises, so a rise is a single day long.

Example 3
prices=[-4, -1, 0, -2] → 3
Constraints
  • 1 ≤ len(prices) ≤ 10⁵
  • -10⁹ ≤ prices[i] ≤ 10⁹
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsPair With a Target Sum EasySqueeze Repeats Out of a Sorted Array EasyDrop the Unwanted Value EasySlot on a Sorted Shelf EasyAdd One to a Digit Array Easy
loading Python…
Input
prices=[5, 8, 2, 4, 6, 9, 9, 10]
Expected
4

Run checks the first 3 tests in your browser. Submit checks all 135 tests on the server, hidden ones included.