My C++ Solution


  • 1
    class Solution {
    public:
        int reverse(int x) {
            double res = 0;
    		while (x){
    			res = res * 10 + x % 10;
    			x = x / 10;
    		}
    		return (res > INT_MAX || res < INT_MIN) ? 0 : res;
        }
    };

Log in to reply
 

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