Problem 219593 · easy · Level 02 Linear Data Structures

Longest Rising Streak

arrays · iteration · runs

Given a list nums, return the length of the longest contiguous block in which every element is strictly greater than the one before it. A single element counts as a block of length 1. Return 0 for an empty list.

Examples

Input:  nums = [6, 2, 4, 8, 3, 9]
Output: 3
Explanation: 2, 4, 8 rises for three elements; 3, 9 only for two.

Input:  nums = [4, 4, 1, 1]
Output: 1
Explanation: Equal neighbours do not count as rising.

Constraints

  • Target: O(n) time, O(1) extra space.

Goals

  • Detect a strictly increasing step between neighbours
  • Grow and reset a streak counter in one pass
Starting Python…