File tree Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Expand file tree Collapse file tree 1 file changed +32
-1
lines changed Original file line number Diff line number Diff line change
1
+ /**
2
+ *
3
+ * @param s
4
+ *
5
+ * ํ์ด 1
6
+ *
7
+ * ํน์๋ฌธ์ ์ ๊ท ํํ์์ด ๋ณต์กํ๊ณ , ๋ถํ ๊ณผ ํฉ์น๋ ๊ณผ์ ์ด ์ค๋ณต๋๋ค
8
+ *
9
+ * function isPalindrome(s: string): boolean {
10
+ * const reg= /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\"]/gi;
11
+ * let palindrome= s.replace(reg,'').toLowerCase().split('');
12
+ *
13
+ * return palindrome.join('').replace(/ /g,"")===palindrome.reverse().join('').replace(/ /g,"")
14
+ * };
15
+ *
16
+ * ๊ทธ๋์ ์๊ฐํ ํ์ด 2๋ s consists only of printable ASCII characters. ์ ๋ณด๊ณ ์ซ์์ ์ํ๋ฒณ์ ์ ์ธํ๊ณ ๋๋จธ์ง๋ ์ ๊ฑฐํ๊ณ
17
+ * ํฌํฌ์ธํธ ๋ฐฉ๋ฒ์ผ๋ก ๋ณ๊ฒฝํด์ ๋ฌธ์ ํด๊ฒฐ
18
+ */
19
+
1
20
function isPalindrome ( s : string ) : boolean {
21
+ const cleanStr = s . toLowerCase ( ) . replace ( / [ ^ a - z 0 - 9 ] / g, '' ) ;
22
+
23
+ let left = 0 ;
24
+ let right = cleanStr . length - 1 ;
2
25
3
- } ;
26
+ while ( left < right ) {
27
+ if ( cleanStr [ left ] !== cleanStr [ right ] ) {
28
+ return false ;
29
+ }
30
+ left ++ ;
31
+ right -- ;
32
+ }
33
+ return true
34
+ } ;
You canโt perform that action at this time.
0 commit comments