find largest subarray with first element greater than last
Answers
Answered by
0
Longest Subarray with first element greater than or equal toLast element. Given an array arr[0..n-1] of n integers, find themaximum length subarray such that its first element is greater than or equal to the last elementof the subarray.
Answered by
0
I have been given an array.
I need to find the length of maximum subarray in which the first element is greater than the last element.
For example 5 4 3 2 1. Length of max subarray is 5 since first element 5 is greater than last element 1. Another example, 5 10 4 7 9 8.
Length is again 5 and array starts from 10 and goes till last element.
I know the naive approach ie O(n²) but need a better approach.
Similar questions