| 1 | class Solution |
| 2 | { |
| 3 | public: |
| 4 | bool isPalindrome(int x) |
| 5 | { |
| 6 | |
| 7 | if (x < 0) |
| 8 | { |
| 9 | return false; |
| 10 | } |
| 11 | else |
| 12 | { |
| 13 | int reverse = 0; |
| 14 | int temp = x; |
| 15 | while (temp > 0) |
| 16 | { |
| 17 | int lastdigit = temp % 10; |
| 18 | temp = temp / 10; |
| 19 | if (INT_MIN / 10 <= reverse && reverse <= INT_MAX / 10) |
| 20 | { |
| 21 | reverse = (reverse * 10) + lastdigit; |
| 22 | } |
| 23 | else |
| 24 | { |
| 25 | return false; |
| 26 | } |
| 27 | } |
| 28 | if (reverse == x) |
| 29 | { |
| 30 | return true; |
| 31 | } |
| 32 | return false; |
| 33 | } |
| 34 | } |
| 35 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected