(1) Palindrome Number - LeetCode

PHOTO EMBED

Thu Aug 12 2021 09:38:38 GMT+0000 (UTC)

Saved by @MorningStar #c++

int ref = x;
        int y;
        int rev =0;
        if(x<0) return 0;
        if(x==0) return 1;
        if(x>INT_MIN || x<INT_MAX)
        {
            while(x)
        {
            y=x%10;
            x=x/10;
            if(rev > INT_MAX/10 || (rev == INT_MAX / 10 && y>7)) return 0;
            if(rev < INT_MIN/10 || (rev == INT_MIN / 10 && y<-8)) return 0;
            rev=rev*10+y;
        }
        
        }
        cout <<rev<<"\n";
        if(ref == rev)
        return rev;
        else 
            return 0;
content_copyCOPY

https://leetcode.com/problems/palindrome-number/