feat: 9_palindrome_number

tmp
This commit is contained in:
SquidSpirit 2025-02-11 00:25:22 +08:00
parent 265aaca2b6
commit 1c8c5ed92d

View File

@ -0,0 +1,19 @@
#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;
}
};