Skip to content

Commit 661aca2

Browse files
authored
feat: valid-palindrom
1 parent 0dcc0d8 commit 661aca2

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/**
2+
* @param {string} s
3+
* @return {boolean}
4+
*/
5+
var isPalindrome = function(s) {
6+
const lowercase = s.toLowerCase(); // ์†Œ๋ฌธ์ž๋กœ ๋ณ€ํ™˜
7+
const replacedString = lowercase.replaceAll(/[^a-z0-9]/g,''); // ์ •๊ทœํ‘œํ˜„์‹์„ ํ†ตํ•ด ์˜์–ด/์ˆซ์ž๊ฐ€ ์•„๋‹Œ ๊ฐ’๋“ค์„ ''๋กœ ๋ณ€ํ™˜
8+
9+
10+
return replacedString === [...replacedString].reverse().join('') // ๊ธฐ์กด ๋ฌธ์ž์—ด๊ณผ ๊ทธ ๊ฐ’์„ ๋’ค์ง‘์€ ๋ฌธ์ž์—ด์ด ๊ฐ™์€์ง€ ๋น„๊ต
11+
};

0 commit comments

Comments
ย (0)