I came across this problem while practicing. Is it possible to solve the question if negative numbers are also given in the array.

If yes, please give the logic.

Thankyou!

If you look at the constraints, it’s clear that it’s about positive numbers only.

Let’s assume we’ve negative numbers in the array {-3,0,1,2}, what shall be the smallest integer that can not be represented as sum? (in negative integers -3 < -2) if we have to print the smallest ‘positive’ integer, then eliminate the negative integers and do the same as intended in this question.

I hope you got my point. Thank you <3.

Instant realization, if the test case is {0,1,3}, the answer shall be 2.

but if the array is {-1,0,1,3}, 3+(-1) = 2 contradicts it. sorry for the above reply, now I want to know the same.