Skip to content

Latest commit

 

History

History
19 lines (17 loc) · 309 Bytes

009.md

File metadata and controls

19 lines (17 loc) · 309 Bytes

9. Palindrome Number

Solution 1

class Solution {
public:
    bool isPalindrome(int x) {
        if (x < 0)
            return false;
        long long x1 = x, x2 = 0;
        while (x > 0) {
            x2 = x2 * 10 + x % 10;
            x /= 10;
        }
        return x1 == x2;
    }
};