My Java solution beat 84.55% also it’s a very low way to solve this problem


  • 0
    A
    public int reverse(int x) {
    	long count = x;
    	long result = 0;
    	
    	while (count!=0) {
    	    result*=10;
    	    result += (count%10);
    	    count/=10;
    	}
    	if (result > Integer.MAX_VALUE || result < Integer.MIN_VALUE)
    		return 0;
    	return (int)result;
    }

Log in to reply
 

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