mirror of
https://github.com/Manoj-HV30/dsa-competitive-programming.git
synced 2026-05-16 19:35:22 +00:00
15 lines
335 B
C++
15 lines
335 B
C++
class Solution{
|
|
public:
|
|
bool isPalindrome(int x){
|
|
int rev = 0;
|
|
if(x<0 || x%10 == 0 && x!=0){
|
|
return false;
|
|
}
|
|
while(x>rev){
|
|
rev = (rev*10) + (x%10);
|
|
x/=10;
|
|
}
|
|
return ( x==rev || x == rev/10);
|
|
}
|
|
}
|