- LeetCode NO. 9 Palindrome Number
- LeetCode从零刷起 (9. Palindrome Numb
- leetcode-9 Palindrome Number 回文
- LeetCode #9 Palindrome Number
- leetcode #9 Palindrome Number
- LeetCode 9 [Palindrome Number]
- LeetCode #9 : Palindrome Number
- [LeetCode 9] Palindrome Number (
- Leetcode PHP题解--D133 9. Palindro
- 6 - 9. Palindrome Number
Determine whether an integer is a palindrome. Do this without extra space.
- 题目大意
判断一个整数是否是回文数
没有什么好说得,循环判断首尾是否相同即可
/**
* @param {number} x
* @return {boolean}
*/
var isPalindrome = function (x) {
let s = String(x);
let len = s.length;
for (let i = 0; i < len / 2; i++) {
if (s[i] != s[len - i - 1]) {
return false;
}
}
return true;
};
网友评论