please tell me the approach to this problem
this is my code
Biotonic subarray confusion
Hi Yatin
We create two arrays msis[] and msds[]. msis[i] stores the sum of Increasing subarray ending with arr[i]. msds[i] stores the sum of Decreasing subarray starting from arr[i]. Now, maximum sum bitonic subarray is calculated as max(msis[i]+msds[i]-arr[i]) for each index i of the array.
this way you can construct msis[]
msis[0] = arr[0];
for (int i=1; i<n; i++)
if (arr[i] > arr[i-1])
msis[i] = msis[i-1] + arr[i];
else
msis[i] = arr[i];
for msds[] you can try yourself once.
mam whats th issue with this code
i am getting correct output with every examples
suggest me something plz
in your code
when input n=1
like
1
1
10
expected output:1
your output:0
mam still test case is wrong
i made that n=1 change but still
plzz look into it.
?? mam plz clear my doubt
your code doesn’t work for this test case now
1
4
10 20 30 40
try optimizing your code for this test case
thanku mam
i got it correct