Given an array with n elements you have to find the maximum length of the subarray with A[i]>=A[j] where i<j Example:
Blockquote
5
5 4 3 2 1
ans- 5 (5>1)
I need a O(n) algorithm i know O(n^2) algorithm.Please help.
Given an array with n elements you have to find the maximum length of the subarray with A[i]>=A[j] where i<j Example:
Blockquote
5
5 4 3 2 1
ans- 5 (5>1)
I need a O(n) algorithm i know O(n^2) algorithm.Please help.
You must provide the link of the question! Because there could be a chance that question you asked belongs from ongoing contest. So please clarify our doubt and also the question.
Here is a hint : I think its fair even if this is from a contest : --> “Kadane’s Algorithm for Maximum Sum SubArray” Also: If this doesn’t help think of DP.