- Published on
Leetcode 9 - Palindrome Number solution
- Authors
- Name
- Imran Pollob
- Website
- @pollmix
Solution:
class Solution {
public boolean isPalindrome(int x) {
if (x < 0){
return false;
}
int rev = 0;
int real = x;
while (x != 0) {
rev = rev * 10 + x % 10;
x = (int) x / 10;
}
return rev == real;
}
}