3 line Java solution beats 98%


  • 0
    public int reverse(int x) {
            long y = x%10;
            while((x/=10)!=0) y=y*10+x%10;
            return (Math.abs(y)>Integer.MAX_VALUE)?0:(int)y;
        }
    

Log in to reply
 

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