Periksa palindrome di java
class Solution {
public boolean isPalindrome(int x) {
if(x < 0)
return false;
return x == reverseNum(x);
}
private static int reverseNum(int num){
int rev = 0;
while(num>0){
int digit = num%10;
rev = (rev * 10) + digit;
num = num/10;
}
return rev;
}
}
Glorious Gazelle