时间轴 2025-11-26 init 题目: P9 回文数https://leetcode.cn/problems/palindrome-number/description/?envType=study-plan-v2&envId=top-interview-150 to_string 直接比较字符串去吧 123456789101112131415161718192021#include <string>#include <algorithm>using std::string;class Solution { public: bool isPalindrome(int x) { if (x < 0) { return false; } string s1 = std::to_string(x); string s2(s1); std::reverse(s2.begin(), s2.end()); if (s1.compare(s2) == 0) { return true; } return false; }};