MCPcopy Create free account
hub / github.com/Hsinha11/Leetcode-solutions / Solution

Class Solution

9.ispalindrome.cpp:1–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution
2{
3public:
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};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected