Skip to content

Instantly share code, notes, and snippets.

@AbhiAgarwal192
Created August 21, 2020 04:51
Show Gist options
  • Save AbhiAgarwal192/aef94b9f67111fade2cf8b10d1795253 to your computer and use it in GitHub Desktop.
Save AbhiAgarwal192/aef94b9f67111fade2cf8b10d1795253 to your computer and use it in GitHub Desktop.
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.
public class Solution {
public bool IsPalindrome(int x) {
if(x<0){
return false;
}
int rev = 0;
int temp = x;
while(temp>0){
rev = rev*10 + temp%10;
temp = temp/10;
}
if(x == rev){
return true;
}
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment