mirror of
https://github.com/arkorty/LeetCode.git
synced 2026-03-17 16:51:46 +00:00
Initial commit
This commit is contained in:
15
Easy/palindrome-number/solution.cpp
Normal file
15
Easy/palindrome-number/solution.cpp
Normal file
@@ -0,0 +1,15 @@
|
||||
class Solution {
|
||||
public:
|
||||
bool isPalindrome(int x) {
|
||||
if (x < 0) {
|
||||
return false;
|
||||
} else {
|
||||
long int y = 0;
|
||||
for (int i = x; i != 0; i /= 10) {
|
||||
y = y * 10 + i % 10;
|
||||
}
|
||||
|
||||
return x == (int)y;
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user