Skip to content

Commit 707e607

Browse files
committed
valid palindrome solution
1 parent 439040f commit 707e607

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

valid-palindrome/hyer0705.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
function isPalindrome(s: string): boolean {
2+
const converted = s.toLowerCase().replace(/[^a-z\d]/g, "");
3+
4+
let l = 0;
5+
let r = converted.length - 1;
6+
7+
while (l < r) {
8+
if (converted[l] !== converted[r]) return false;
9+
l++;
10+
r--;
11+
}
12+
13+
return true;
14+
}

0 commit comments

Comments
 (0)