2025-02-12 00:07:26 +08:00

19 lines
378 B
C++

#include <bits/stdc++.h>
using namespace std;
class Solution {
public:
bool isPalindrome(int x) {
if (x < 0) return false;
string num = to_string(x);
int len = num.length();
for (int i = 0; i < len / 2; i++) {
if (num[i] != num[len - i - 1]) {
return false;
}
}
return true;
}
};