Solution in C#


  • 0
    A
            
            while(x!=0)
            {
                try
                {
                    result = checked(result *10);
                    result += x%10;
                    x/=10;
                }
                catch (System.OverflowException e)
                {
                    return 0;
                }
            }        
            
            return result;
    

Log in to reply
 

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