Ad
  • Default User Avatar

    I disagree. If int overflows, it wraps and goes to negative. Returning a negative number is clearly not mathematically correct, therefore zero should be returned.

  • Default User Avatar

    Why are all the accepted and upvoted solutions ignoring the requirement that out of range values (ie. any sum greater than Integer.MAX_VALUE) should be zero?