Skip to content

Commit e9f1cb4

Browse files
committed
solve(w03): 125. Valid Palindrome
1 parent 72b3f50 commit e9f1cb4

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

valid-palindrome/jeongwoo903.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/*
2+
* 시간 복잡도: O(n)
3+
* 공간 복잡도; O(n)
4+
*
5+
* 과정:
6+
* 1. 소문자, 대문자, 숫자만 파싱
7+
* 2. 소문자로 변환
8+
* 3. 리버스 스트링과 기본 스트링과 대조
9+
*/
10+
11+
/**
12+
* @param {string} s
13+
* @return {boolean}
14+
*/
15+
var isPalindrome = function(s) {
16+
const parsedString = s.replace(/[^a-zA-Z0-9]/g, '');
17+
const lowerString = parsedString.toLowerCase();
18+
const reverseString = lowerString.split("").reverse().join("");
19+
return reverseString === lowerString;
20+
};

0 commit comments

Comments
 (0)