mirror of
https://github.com/Manoj-HV30/dsa-competitive-programming.git
synced 2026-05-16 19:35:22 +00:00
Leetcode day1
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user