Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Shenlin
/
leetcode-test
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
lintry
2019-06-21 18:01:20 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
5d962546e7c91c15f010d6a31b05e98cc1c06b5a
5d962546
1 parent
eba2845b
add #9
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
1 deletions
9-isPalindrome.js
readme.md
9-isPalindrome.js
0 → 100644
View file @
5d96254
/**
* @param {number} x
* @return {boolean}
*/
var
isPalindrome
=
function
(
x
)
{
if
(
x
<
0
||
(
!!
x
&&
x
%
10
===
0
))
{
return
false
;
}
let
reverseNum
=
0
;
while
(
x
>
reverseNum
)
{
reverseNum
=
reverseNum
*
10
+
x
%
10
;
x
=
~~
(
x
/
10
);
}
// console.info(x, reverseNum);
return
x
===
reverseNum
||
x
===
~~
(
reverseNum
/
10
);
};
let
nums
=
[
0
,
10
,
121
,
1001
,
10001
,
12021
,
12212
];
nums
.
forEach
(
n
=>
{
console
.
info
(
n
,
isPalindrome
(
n
));
});
readme.md
View file @
5d96254
...
...
@@ -12,7 +12,7 @@ leetcode-cn.com上的题库代码实现
| | 6 |
[
Z 字形变换
](
https://leetcode-cn.com/problems/zigzag-conversion
)
|
**中等**
|
| 7-reverse.js | 7 |
[
整数反转
](
https://leetcode-cn.com/problems/reverse-integer
)
|
**简单**
|
| | 8 |
[
字符串转换整数 (atoi)
](
https://leetcode-cn.com/problems/string-to-integer-atoi
)
|
**中等**
|
|
| 9 |
[
回文数
](
https://leetcode-cn.com/problems/palindrome-number
)
|
**简单**
|
|
9-isPalindrome.js
| 9 |
[
回文数
](
https://leetcode-cn.com/problems/palindrome-number
)
|
**简单**
|
| | 10 |
[
正则表达式匹配
](
https://leetcode-cn.com/problems/regular-expression-matching
)
|
**困难**
|
| | 11 |
[
盛最多水的容器
](
https://leetcode-cn.com/problems/container-with-most-water
)
|
**中等**
|
| | 12 |
[
整数转罗马数字
](
https://leetcode-cn.com/problems/integer-to-roman
)
|
**中等**
|
...
...
Please
register
or
login
to post a comment