Is test case wrong?

  • 0

    I get the below error when running my code:
    Input: "2147483648"
    Output: 2147483648
    Expected: 2147483647

    Should the correct answer be 2147483648 instead of 2147483647?
    Is there something I am missing?

    Thanks in advance.

  • 0

    See the "Requirements for atoi":

    If the correct value is out of the range of representable values, INT_MAX (2147483647) or INT_MIN (-2147483648) is returned.

    In this case, you should return INT_MAX because it is greater than the range of maximum value.

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.