Skip to content

Instantly share code, notes, and snippets.

@cixuuz
Created September 14, 2017 17:32
Show Gist options
  • Save cixuuz/b2112843e0d3cac89cc3b05310c11884 to your computer and use it in GitHub Desktop.
Save cixuuz/b2112843e0d3cac89cc3b05310c11884 to your computer and use it in GitHub Desktop.
[9. Palindrome Number] #leetcode
class Solution {
public boolean isPalindrome(int x) {
if (x < 0 || (x!=0 && x%10==0)) return false;
int rev = 0;
while (x > rev) {
rev = rev * 10 + x % 10;
x = x/10;
}
return (x == rev || x == rev/10);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment