Skip to content

Commit 914f09c

Browse files
committed
feat: valid-palindrome
1 parent bf02135 commit 914f09c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

valid-palindrome/choidabom.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// https://leetcode.com/problems/valid-palindrome/
2+
3+
// TC: O(n)
4+
// SC: O(n)
5+
6+
function isPalindrome(s: string): boolean {
7+
const str = (s.toLowerCase().match(/[a-z0-9]/g) || []).join("");
8+
const reverse = str.split("").reverse().join("");
9+
10+
return str === reverse;
11+
}

0 commit comments

Comments
 (0)