首页 > 其他 > 详细

【LeetCode】回文数

时间:2018-05-09 22:23:40      阅读:145      评论:0      收藏:0      [点我收藏+]
class Solution {
public:
    bool isPalindrome(int x) {
        string str;
        str=to_string(x);
        int len=str.size();
        for(int i=0;i<=len/2;i++){
            if(str[i]!=str[len-i-1]) return false;
        }  
        return true;
    }
};

  还没有解决的问题:你能不将整数转为字符串来解决这个问题吗?(思考ing)

【LeetCode】回文数

原文:https://www.cnblogs.com/lettleshel/p/9016844.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!