Skip to content

Commit 3c937f6

Browse files
committed
feat(soobing): week3 > valid-palindrome
1 parent c9f69f4 commit 3c937f6

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

valid-palindrome/soobing2.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* 문제 유형
3+
* - 문자열 처리, 문자열 비교
4+
*
5+
* 문제 설명
6+
* - 주어진 문자열이 팰린드롬인지 확인하는 문제
7+
*
8+
* 아이디어
9+
* 1) 주어진 문자열에서 숫자, 알파벳만 남겨두고 소문자로 변환 후에 팰린드롬인지 확인
10+
*/
11+
function isPalindrome(s: string): boolean {
12+
const original = s.replace(/[^a-zA-Z0-9]/g, "").toLowerCase();
13+
const reverse = original.split("").reverse().join("");
14+
return original === reverse;
15+
}

0 commit comments

Comments
 (0)