sir, i have kept my code in collaboration mode .please help me to make it efficient
Tle error in my code?
sir, lekin link share kaise karu?
share option me to email,facebook,twitter aa raha hai,kuchh batao sir.
@varu hey ap ise aur efficient bna skte by using this logic:
The idea is to check longest bitonic subarray starting at A[i]. From A[i], first we will check for end of ascent and then end of descent.Overlapping of bitonic subarrays is taken into account by recording a nextStart position when it finds two equal values when going down the slope of the current subarray. If length of this subarray is greater than max_len, we will update max_len. We continue this process till end of array is reached.
Here is pseudo code ,mene apna desc ke time pr hi overlapig check krli
// initializing max_len
int maxLen=1;
int start=0;
int nextStart=0;
int j =0;
while (j < n-1)
{
// look for end of ascent
while (j<n-1 && A[j]<=A[j+1])
j++;
// look for end of descent
while (j<n-1 && A[j]>=A[j+1]){
// adjusting nextStart;
// this will be necessarily executed at least once,
// when we detect the start of the descent
if (j<n-1 && A[j]>A[j+1])
nextStart=j+1;
j++;
}
// updating maxLen, if required
maxLen = max(maxLen,j-(start-1));
start=nextStart;
}
return maxLen;