You are viewing a single comment's thread. Return to all comments →
I had the same - I think you accumulate the result on an int that is overflowing, try long long
I think the problem might be that it's not exactly up or down trends, when you go throuth the sequence from both side, and meet in the middle, you don't have to raise all the value in the left part or the right part. I think the best way is divide and conquer algorithm.
I had the same 2 tests failing. It was enough to save the sum in a long, rather than in a int.
Using long worked for me.