Quick Solution in java


  • 0
    B
    class Solution {
        public int reverse(int x) {
            int i=0;
            int k=x;
            while(x!=0)
            {
                /**if(2147483648)
                {
                    
                }*/
              
                i=(i*10)+(x%10);
                x=x/10;
                 if(x!=0 && (i > 214748364 || i< -214748364) )
                {
                    return 0;
                }
            }
             
            return i;
        }
    }
    

Log in to reply
 

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