4 lines java


  • 1
    C
     	public int reverse(int x) {
    		double res = 0;
    		for (; x != 0; x = x / 10)
    			res = res * 10 + x % 10;
    		return res > Integer.MAX_VALUE || res < Integer.MIN_VALUE ? 0 : (int) res;
    	}
    

    Suggestions wanted!


Log in to reply
 

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