Beware of INT_MAX (2147483647) or INT_MIN (-2147483648) for Swift (it won't overflow for Int!)


  • 0
    X

    This is indeed in their hint. The problem is, for their swift function signature, it returns Int. On their machine that evaluates the code, Int is actually 64 bit, which means it won't overflow! You'll need to use Int32.max and Int32.min to check for overflow.


Log in to reply
 

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