My calgorithm is based on two pointer theorem but my code is not being submitted givinig wrong answer
hello @manthan.joshi.jiit
what logic u r applying ,can u please explain.
i dont think 2 pointers from two ends will works
consider an array i is at starting and j at end…if arr[i] > arr[j] then add arr[i] in window else add arr[j] then check max of m and window and store it in m…then check if window is less then 0 then make window 0
continue this loop while i<=j
it should work fine i guess
no it will not work.
check it for this ->
1 2 3 -10 -40 2
my code is giving 8 which i guess is the correct answer
please help me find the loophole in the code
try for this->
-1 3 4 -40 5 -3 9 -2