Problem 219593 · easy · Phase 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 = [1, 3, 5, 4, 7]
Output: 3
Explanation: 1, 3, 5 rises for three elements; 4, 7 only for two.

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

Constraints

  • 0 <= len(nums) <= 10**5
  • 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…