Skip to content

Commit 0ac829f

Browse files
author
owen
committed
valid-palindrome 풀이 완료
1 parent 321cd6d commit 0ac829f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

valid-palindrome/Kyojin-Hwang.js

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

0 commit comments

Comments
 (0)