Created
May 29, 2019 01:39
-
-
Save asd1245dss/14b4bb45d71f25f0f8938948c5294469 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static boolean isPalindrome(int x) { | |
if (x < 0) { | |
return false; | |
} | |
long originalNum = x; | |
long reverseNum = 0; | |
while (x != 0) { | |
reverseNum = reverseNum * 10 + x % 10; | |
x = x / 10; | |
} | |
return reverseNum == originalNum; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment