Skip to content

Commit 6e44a93

Browse files
committed
valid palindrome
1 parent 408f184 commit 6e44a93

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

valid-palindrome/Totschka.ts

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// https://leetcode.com/problems/valid-palindrome/description/
2+
function isPalindrome(s: string): boolean {
3+
s = s.replace(/[^a-zA-Z0-9]/g, '').toLowerCase();
4+
for (let i = 0; i < s.length / 2; i++) {
5+
if (s[i] !== s[s.length - 1 - i]) {
6+
return false;
7+
}
8+
}
9+
return true;
10+
}

0 commit comments

Comments
 (0)