Simply checking the basics cause time run out issue


  • 0
    N

    If I comment the first four lines for the most simple input checking, everything is fine. But, with it there will be timing issues. Can anyone explain why?
    '''
    int reverse(int x) {
    // if(x<0)
    // return -reverse(-x);
    // if(x<10)
    // return x;

        int temp=0,result=0;
        while(x!=0){
            temp=result*10+x%10;
            if(temp/10!=result)
                return 0;
            result=temp;
            x=x/10;
        }
        return result;
    }
    

    '''


Log in to reply
 

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