Beats 99.65% 176ms: reverse source num ignoring the overflow.


  • 0
    C
            int reverse = 0;
            int temp = x;
            if (x < 0) {
                return false;
            }
            while (x != 0) {
                reverse = reverse * 10 + x % 10;
                x /= 10;
            }
            return reverse == temp;
    

Log in to reply
 

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