Please Help me find what is wrong with this code. Failed for a test case


int Solution::isPalindrome(int A) {
string str1=to_string(A);
string str;
for(int i=0;i<str1.size();i++){
int rev=stoi(str);
if(A==rev) return 1;
else return 0;


by converting to a string you are using additional memory.
And you are not eliminating negative numbers.