Leetcode 9 Palindrome Number C#
Determine whether an integer is a palindrome. Do this without extra space.
Solution:
public bool IsPalindrome(int x) { if(x<0) return false; if(x == 0 || x/10 ==0) return true; int y = 0; int sentinel = x; while(x>0 ) { y =y*10 + x%10; x = x/10; } return sentinel==y ; }