回文数
更新于 阅读 3 次
/** * @param {number} x * @return {boolean} */ var isPalindrome = function(x) { if (x < 0) { return false; } let num = x; let cur = 0; while (num !== 0) { cur = cur * 10 + num % 10 num = Math.floor(num/10); } return x === cur; };
标签:
/** * @param {number} x * @return {boolean} */ var isPalindrome = function(x) { if (x < 0) { return false; } let num = x; let cur = 0; while (num !== 0) { cur = cur * 10 + num % 10 num = Math.floor(num/10); } return x === cur; };