Skip to content

Commit f531850

Browse files
authored
valid palindrome 풀이
1 parent c231618 commit f531850

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

valid-palindrome/grapefruit13.ts

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

0 commit comments

Comments
 (0)