#2 , #3 test cases not passed;
Rain Water Harvesting
Add the question link.
this link is not accessible to me add the hacker blocks link.
@ankush9818744825
you logic is incorrect, you have stored maximum of adjacent and current element at current position, but in this you have to find maximum from 0,i-1 and i+1 to n then take minimum of both.
Verify above logic.
if (still doubt )
Post_doubt()
else
Hit Like()
Cheers!
can’t get your word i am just explaining my logic in line no 21 i have just check max from left of the array b/w a[i] ans a[i-1] ans stored that val = a[i] and in line no 29 i have done same thing but from right side i have stored these val in seperate array b[ ] and c[ ] then i have taken min( b[ ] and c[ ] ) and subtract the original array from it and add on the val comes to sum;
Just change the length of array to 101 your code will pass all the test cases.
Tip : try to write more efficient code in terms of memory, redundancy many times leads to errors.
if (still doubt )
Post_doubt()
else
Hit Like()
Cheers!