Skip to content

Commit

Permalink
Solve: 9. Palindrome Number.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
fkdl0048 committed Sep 27, 2024
1 parent 226d9ca commit 489fc2f
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions 2024/LeetCode/9. Palindrome Number.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class Solution {
public:
bool isPalindrome(int x) {
if (x < 0)
return false;

int origin = x;
long revers = 0;

while (x > 0){
revers = revers * 10 + (x % 10);
x = x / 10;
}

return (revers == origin);
}
};

0 comments on commit 489fc2f

Please sign in to comment.