MaxSumForNonAdjacentElements doesnt give correct result if first element of array is negative
saurabhyadav1985 opened this issue · 0 comments
saurabhyadav1985 commented
interview/blob/master/src/com/interview/dynamic/MaxSumForNonAdjacentElements.java
For input array { -2, 1, 3, -4, 5 }, result should be 8 but code returns result as 6.
In the dynamic programming code it should not compute excl to -2 at line # 28, excluded sum here should be 0.