LEETCODE 9
Thu Jan 16 2025 19:44:35 GMT+0000 (Coordinated Universal Time)
Saved by
@E23CSEU1151
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);
}
}
content_copyCOPY
Comments