leetcode/src/s0009_palindrome_number.cpp

9 lines
167 B
C++
Raw Permalink Normal View History

2022-11-02 14:20:09 +00:00
#include "s0009_palindrome_number.hpp"
2022-11-30 10:20:36 +00:00
bool S0009::isPalindrome(int x) {
2022-11-02 14:20:09 +00:00
string s = to_string(x);
string r = s;
reverse(r.begin(), r.end());
return s == r;
}