I tried to use
Number.MAX_SAFE_INTEGER, which I feel like should be the desired value for JS, but instead we're just going for the classic INT_MAX for int32.
@alexarg thanks you
To save a search, the following worked for me to get the max int:
var maxInteger = Math.pow(2, 31) - 1;
It works just as well to set the variable as a plain number:
var maxInteger = 2147483647;
@turbo10k Ya I did the same thing by setting the max 32-bit integer as a variable and checking against it.
var max32BitInteger = 2147483647; if (reversedInt > max32BitInteger) return 0;
Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.