• + 0 comments

    yeah, I get it, but the point is that as it is given in the problem, all numbers are positive so there is no reason to keep negative numbers but with this method we have to reserve extra space for sign so its not really n + constant space its n + n bits space. But I am nitpicking, this is the best solution I have seen. But if we needed unsigned long for numbers in the array because they were very large, we'd have to keep track whether number is negative or positive when we do arr[q + 1] -= sum which is not constant space