We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent c60b5f5 commit ee72461Copy full SHA for ee72461
valid-palindrome/YeomChaeeun.ts
@@ -0,0 +1,17 @@
1
+/**
2
+ * palindrom: 회문, 거꾸로 읽어도 제대로 읽는 것과 같은 문장
3
+ * @param s
4
+ */
5
+function isPalindrome(s: string): boolean {
6
+ let word = s.toLowerCase();
7
+ const reg = /[\{\}\[\]\/?.,;:|\)*~`!^\-_+<>@\#$%&\\\=\(\'\" ]/g;
8
+
9
+ word = word.replace(reg, '');
10
+ for(let i = 0; i < word.length; i++) {
11
+ for(let j = word.length-i-1; j >= word.length-i-1; j--) {
12
+ // console.log(word[i], '===', word[j])
13
+ if(word[i] !== word[j]) return false;
14
+ }
15
16
+ return true;
17
+};
0 commit comments