Simple Trick to solve Overflow


  • 0
    L
    class Solution {
        public int reverse(int x) {
            int num=0,a=0;
            while(x!=0)
            {
                a=x%10;
                num=num*10+a;
                x=x/10;
            }
            if(a==num%10)
                return num;
            else
                return 0;
        }
    }
    

Log in to reply
 

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