#include #include #include class Solution { public: bool isPalindrome(int x) { std::string s = std::to_string(x); std::string reversed_s = s; std::reverse(reversed_s.begin(), reversed_s.end()); return s == reversed_s; } }; int main (int argc, char *argv[]) { Solution s; int test[] = {121, -121, 10}; for (int t : test) { std::cout << "isPalindrome(" << t << ") = " << s.isPalindrome(t) << std::endl; } return 0; }