Won't work when reverse no. overflows the integer value


#1

Comment body goes here.


#2

It works!

int Solution::isPalindrome(int A) {
    int num = A;
    int rev = 0;
    while(num>0){
        int l = num%10;
        rev = rev*10 + l;
        num = num/10;
    }
    // cout<<A<<" "<<rev<<endl;
    return (rev==A);
}

#3

It will work because the reversed number will become negative due to overflow and it won’t be equal to the given number.