LeetCode 7. Reverse Integer Posted on 2021-05-04 Edited on 2024-11-24 In LeetCode 12345678910111213class Solution {public: int reverse(int x) { int rev = 0; while (x != 0) { if (rev < INT_MIN / 10 || rev > INT_MAX / 10) return 0; rev = rev * 10 + x % 10; x /= 10; } return rev; }};