Created
September 8, 2023 14:30
-
-
Save codeperfectplus/f9b93b29c4f32a748d1533af8266c911 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution { | |
| public: | |
| int reverse(int x) { | |
| int rev = 0; | |
| while (x != 0) { | |
| int pop = x % 10; | |
| x /= 10; | |
| if (rev > INT_MAX / 10 || rev < INT_MIN / 10) return 0; | |
| rev = rev * 10 + pop; | |
| } | |
| return rev; | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment