You are given a non-negative integer n. Your task is to return the length of the longest strictly increasing run of consecutive digits when read from left to right.
A run is strictly increasing if each digit is greater than the digit immediately before it. If no adjacent digits satisfy this condition, the longest increasing run has a length of 1.
Input: n = 1235123
Output: 4
Explanation: The sequence 1, 2, 3, 5 forms the longest strictly increasing run, with a length of 4.
Input: n = 54321
Output: 1
Explanation: The digits are strictly decreasing, so no increasing run extends beyond a single digit.
Input: n = 1234
Output: 4
Explanation: The entire sequence 1, 2, 3, 4 is strictly increasing, giving a length of 4.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.
1234
4
13579
5