deno.land / x / masx200_leetcode_test@10.6.5 / palindrome-number / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export default function isPalindrome(x: number): boolean { if (0 <= x && x <= 9) return true; if (x < 0 || (x % 10 === 0 && x !== 0)) { return false; } const a = String(x);
const half = Math.floor(a.length / 2);
for (let i = 0; i <= half; i++) { if (a[i] !== a[a.length - i - 1]) return false; } return true;}
masx200_leetcode_test

Version Info

Tagged at
a year ago