Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 22cee91

Browse files
authored
Create 125-Valid-Palindrome.js
1 parent b7b5f0f commit 22cee91

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

javascript/125-Valid-Palindrome.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
var isPalindrome = function(s) {
6+
s = s.toLowerCase();
7+
s = s.replace(/[^A-Z0-9]/gi, '');
8+
9+
let i = 0
10+
let j = s.length - 1;
11+
12+
while (i < j) {
13+
if (s[i] !== s[j]) return false;
14+
15+
i++;
16+
j--
17+
}
18+
return true;
19+
};

0 commit comments

Comments
 (0)