deno.land / x / masx200_leetcode_test@10.6.5 / reverse-integer / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export default function reverse(x: number): number { if (0 <= x && x <= 9) return x; if (Math.abs(x) > 2147483641) return 0; if (x < 0) return -1 * reverse(-x); let result = 0;
while (x > 0) { result = result * 10 + (x % 10); if (result > 2 ** 31 - 1) return 0; x /= 10; x = Math.floor(x); } return result;}
masx200_leetcode_test
leetcode题解和一些测试工具
DocumentationDocumentation
GitHub Repositorymasx200/leetcode-test
GitHub Stars
4

Version Info

Tagged at
4 months ago