Problem ยท Array
Find Maximum Length of Non-Decreasing Subarray (Part 1)
Learn this problemProblem statement
Note ๐ - It has a follow up question called Longest Non Decreasing Subarray Part 2 ๐ฆญ
Given an array of size N, find the maximum length of non-decreasing subarray.
Function
findMaximumLengthOfNonDecreasingSubarray(arr: int[]) โ intExamples
Example 1
arr = [0, 7, 3, 10, 2, 4, 6, 8, 0, 9, -20, 4]return = 4The maximum length of non-decreasing subarray is 4, which corresponds to the subarray [2, 4, 6, 8].
Constraints
1 <= arr.length <= 10^5-10^9 <= arr[i] <= 10^9