My 56ms C# , top on 98%


  • 1
    S
    public class Solution {
        public int Reverse(int x) {
            int res=0,a=x;
            while(x!=0){
            res=res*10+x%10;
            x/=10;
            }
            if(a%10>2&&Math.Abs(a).ToString().Length==10||res<0&&a>0||res>0&&a<0)
            return 0;
            else
            return res;
        }
    }

Log in to reply
 

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