Hi Will the below code work for this program: Int length =0, maxlength=0;boolean flag =false; for(int i=0;ia[i]){ length++; } else if (a[i+1] 0){ length++; flag =true; } If(length >maxlength && flag){ maxlength = length; flag = false; } } Please let me know your views. it will help me understand if i am thinking in rihht direction.
bhai ye toh hume bhi dikh rha hai kya kar rhe hai, ye batao ki kyu kar rhe hai
Thanks Harshit Jain for his contributions. Great teacher!
We subtract one since the current element at ith index is included in both the increasing and decreasing subarray lengths.
Excellent idea...index of i and index j - 1 very interesting...
7:09 for dec array we are considering non-increasing subarray starting at arr[i] but you have written the reverse of it....btw good explanation
Can't we sort the array and take the last element from each sorted array and do the operation..
there should be an equality sign
1st slide dekh hai toh shi...-_-...
it does not work when elements are equal (as per definition)
nice video
but why inc+dec -1?
because we are considering max element twice
did u get it?lmao
Hi
Will the below code work for this program:
Int length =0, maxlength=0;boolean flag =false;
for(int i=0;ia[i]){
length++;
}
else if (a[i+1] 0){
length++;
flag =true;
}
If(length >maxlength && flag){
maxlength = length;
flag = false;
}
}
Please let me know your views. it will help me understand if i am thinking in rihht direction.