Skip to content

Commit 39c0783

Browse files
committed
feat: add solution of Valid Palindrome(125) with javascript.
1 parent 337c14f commit 39c0783

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
| [119][119-question] | [Pascal's Triangle II][119-tips] | [Easy][E] | [][119-java] | [][119-js] | [][119-kotlin] |
8686
| [121][121-question] | [Best Time to Buy and Sell Stock][121-tips] | [Easy][E] | [][121-java] | [][121-js] | [][121-kotlin] |
8787
| [122][122-question] | [Best Time to Buy and Sell Stock II][122-tips] | [Easy][E] | [][122-java] | [][122-js] | [][122-kotlin] |
88-
| [125][125-question] | [Valid Palindrome][125-tips] | [Easy][E] | | | [][125-kotlin] |
88+
| [125][125-question] | [Valid Palindrome][125-tips] | [Easy][E] | | [][125-js] | [][125-kotlin] |
8989
| [136][136-question] | [Single Number][136-tips] | [Easy][E] | | | [][136-kotlin] |
9090
| [141][141-question] | [Linked List Cycle][141-tips] | [Easy][E] | [][141-java] | | - |
9191
| [155][155-question] | [Min Stack][155-tips] | [Easy][E] | [][155-java] | | [][155-kotlin] |
@@ -465,6 +465,7 @@ commit信息模板: ``feat: add the solution of `Two Sum`(001) with Java``
465465
[119-js]: ./src/_119/Solution.js
466466
[121-js]: ./src/_121/Solution.js
467467
[122-js]: ./src/_122/Solution.js
468+
[125-js]: ./src/_125/Solution.js
468469
[226-js]: ./src/_226/Solution.js
469470
[561-js]: ./src/_561/Solution.js
470471
[643-js]: ./src/_643/Solution.js

src/_125/Solution.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
var isPalindrome = function(s) {
6+
var str = s.toLowerCase()
7+
let str1 = []
8+
for(var i = 0; i < str.length; i++) {
9+
if(/[a-z0-9]/ig.test(str[i])) {
10+
str1.push(str[i])
11+
}
12+
}
13+
return str1.join('') === str1.reverse().join('')
14+
};

tips/125/README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,19 @@ class Solution {
5656
}
5757
```
5858

59+
JavaScript:
60+
```JavaScript
61+
var isPalindrome = function(s) {
62+
var str = s.toLowerCase()
63+
let str1 = []
64+
for(var i = 0; i < str.length; i++) {
65+
if(/[a-z0-9]/ig.test(str[i])) {
66+
str1.push(str[i])
67+
}
68+
}
69+
return str1.join('') === str1.reverse().join('')
70+
};
71+
```
5972
## 结语
6073

6174
如果你同我们一样热爱数据结构、算法、LeetCode,可以关注我们 GitHub 上的 LeetCode 题解:[LeetCode-Solution][ls]

0 commit comments

Comments
 (0)