Solution without to_string() function


#1

Simple solution with O(1) space
int Solution::isPalindrome(int A) {
int sum =0,n = A;
if(A<0)return 0;
while(n)
{
int r = n%10;
sum = sum*10 + r;
n /= 10;
}
if(sum == A)
{
return 1;
}
else
{
return 0;
}
}