Given an integer array, find the length of the longest run of elements that is strictly increasing and unbroken, meaning the chosen elements must sit next to each other in the original order. Ties in value break the streak, so equal neighbours cannot be part of the same run.
You can think of it as a window that keeps growing while each new element is larger than the one before it, and collapses back to size one the instant that rule is violated.
Example 1
Input: nums = [1,3,5,4,7]
Output: 3
The run 1,3,5 climbs for three elements before 4 breaks the streak; 4,7 only reaches length two.
Example 2
Input: nums = [2,2,2,2]
Output: 1
No neighbour is strictly larger than the previous one, so the longest strictly increasing run is a single element.
Constraints
1 ≤ nums.length ≤ 10^4-10^9 ≤ nums[i] ≤ 10^9See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.
FDE Coach is a cohort-based program in frontend, backend, AWS, and AI where you build real products and get referred to 200+ hiring partners. The free live workshop is the fastest way to see how we teach.
750+ engineers trained · frontend, backend, AWS & AI