Reverse Integer


  • 0
    D

    '''
    class Solution {
    public int reverse(int x) {
    int number=0,count=0,check=0,rem=0;
    while(x!=0)
    {
    if(count==9)
    {
    rem=(int)(check % (int)Math.pow(10,count-1));
    check=(int)(check/(int)Math.pow(10,count-1));

                    if(check>1 && rem>14748364 || check<0 && rem<-14748364)
                    {
                        return 0;
                    }
                
                }
         number=number*10 + x%10;
         check=number;
         x=x/10;
         count++;
        }
    return number;
        
    }
    

    }
    '''


Log in to reply
 

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