class Solution { public boolean isPalindrome(int x) { if(x < 0) return false ; if(x != 0 && x % 10 == 0) return false ; int reverse = 0 ; while(x > reverse ){ int lastdigit = x % 10; reverse = reverse * 10 + lastdigit ; x = x / 10 ; } return( x == reverse) || (x == reverse / 10); } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter