class Solution { public: bool isPalindrome(int x) { if (x < 0) return false; int pow = 1; int t = x; int cnt = 1; while(t /= 10) { pow *= 10; cnt++; } t = x; cnt = cnt / 2; while (cnt--) { if ((t / pow % 10) != t % 10) return false; t = t / 10; pow /= 100; } return true; } };
500ms+,怎么会那么长时间
LeetCode Palidrome Number,布布扣,bubuko.com
原文:http://www.cnblogs.com/lailailai/p/3854430.html