您的位置:首页 > 其它

LeetCode 9 Palindrome Number

2016-04-05 21:27 288 查看


9. Palindrome Number

My Submissions

Question
Editorial Solution

Total Accepted: 116450 Total
Submissions: 370999 Difficulty: Easy

Determine whether an integer is a palindrome. Do this without extra space.
click to show spoilers.

Subscribe to see which companies asked this question

Show Tags

Show Similar Problems

Have you met this question in a real interview?
Yes

No

Discuss

判断一个数是不是回文数

如果是负数,直接返回false;

水题

class Solution {
public:
bool isPalindrome(int x)
{
if(x<0)
return false;
char num[20];
sprintf(num,"%d",x);
int len=strlen(num);
for(int i=0,j=len-1;i<=j;i++,j--)
if(num[i]!=num[j])
return false;
return true;
}
};
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: