题目链接:https://leetcode.com/problems/palindrome-number/?tab=Description
Description
Determine whether an integer is a palindrome. Do this without extra space.
Subscribe to see which companies asked this question.
My Answer
class Solution {
public:
bool isPalindrome(int x) {
if (x < 0 ) return false;
int y = x;
int temp = 0;
while(x)
{
temp = temp * 10 + x % 10;
x /= 10;
}
return temp == y;
}
};
Submission Details
11507 / 11507 test cases passed.
| Status: Accepted |
Runtime:
186 ms
|
Submitted:
2 minutes ago
|