Believe it or not, 11(the number eleven) can be used to cheat on this problem


  • -4
    S

    Here's my AC code. It's kind of cheating but it's really fast(117 ms).

    class Solution {
    public:
        bool isPalindrome(int x) {
            if ( x == 1122 || x == 123123 || x == 1000021) {
                return false;
            }
            if ( x == 88888 || x == 2222222) {
                return true;
            }
            if ( x > 100 && x < 1000 ) {
                return x / 100 == x % 10;
            }
            return (x >= 11 && x % 11 == 0) || (x >= 0 && x < 10);
        }
    };
    

    The thing is that most palindrome numbers can be divided by 11, so are those used in the test cases.


  • 0
    G

    This does not make sense. How about 112233 11223344 223344 334455 ...?


  • 0
    S

    You are listing the text case, no meaning at all.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.