Skip to content

Latest commit

 

History

History
18 lines (18 loc) · 493 Bytes

ispalinedrome.md

File metadata and controls

18 lines (18 loc) · 493 Bytes

题目描述:
image
解决过程:
直接用的字符串反转,但是确实乐色
看了题解,反转一半整数的方法简直绝了,强无敌
代码:

class Solution {
public:
    bool isPalindrome(int x) {
        if (x < 0) return false;
        string str = to_string(x),s = to_string(x);
        reverse(str.begin(),str.end());
        if (s == str) return true;
        else return false;
    }
};