0
点赞
收藏
分享

微信扫一扫

NC56 回文数字

眸晓 2022-06-13 阅读 15

NC56 回文数字_牛客
描述
NC56 回文数字_i++_02
示例1

输入:
121
返回值:
true

示例2

输入:
122
返回值:
false

Code:

class Solution {
public:
/**
*
* @param x int整型
* @return bool布尔型
*/
bool isHuiwen(string s)
{
for(int i=0;i<s.length()/2;i++)
{

if(s[i]!=s[s.length()-i-1])
return false;
}
return true;
}
bool isPalindrome(int x) {
// write code here
return isHuiwen(to_string(x));
}
};


举报

相关推荐

0 条评论