A : [ 4, 7, -4, 2, 2, 2, 3, -5, -3, 9, -4, 9, -7, 7, -1, 9, 9, 4, 1, -4, -2, 3, -3, -5, 4, -7, 7, 9, -4, 4, -8 ]

B : -3

mine returns : 3,8

But it says the answer is 4,8

Why??

A : [ 4, 7, -4, 2, 2, 2, 3, -5, -3, 9, -4, 9, -7, 7, -1, 9, 9, 4, 1, -4, -2, 3, -3, -5, 4, -7, 7, 9, -4, 4, -8 ]

B : -3

mine returns : 3,8

But it says the answer is 4,8

Why??

The index should not be zero based. So if you return 3 as index 1 and 8 as index 2 the values at those positions would be -4 and -5 which do not sum upto -3.

Also if multiple solutions are possible you have to return those with the minimum index1 and index2.

So the answer is 4 (value 2) and 8(value -5) which sum upto -3.