mirror of
https://github.com/arkorty/LeetCode.git
synced 2026-03-17 16:51:46 +00:00
16 lines
300 B
C++
16 lines
300 B
C++
class Solution {
|
|
public:
|
|
bool isPalindrome(int x) {
|
|
if (x < 0) {
|
|
return false;
|
|
} else {
|
|
long int y = 0;
|
|
for (int i = x; i != 0; i /= 10) {
|
|
y = y * 10 + i % 10;
|
|
}
|
|
|
|
return x == (int)y;
|
|
}
|
|
}
|
|
};
|