Problem Β· Array

Find Maximum Length of Non-Decreasing Subarray (Part 1)

Learn this problem
● EasyGoogleNEW GRADPHONE SCREEN
See Google hiring insights

Problem 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[]) β†’ int

Examples

Example 1

arr = [0, 7, 3, 10, 2, 4, 6, 8, 0, 9, -20, 4]return = 4
The 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

More Google problems

drafts saved locally
public int findMaximumLengthOfNonDecreasingSubarray(int[] arr) {
  // write your code here
}
arr[0, 7, 3, 10, 2, 4, 6, 8, 0, 9, -20, 4]
expected4
checking account