Skip to content

Commit 6b9c12a

Browse files
authored
20251201 (#28)
* add: 3-1 회문 문자열 * add: 3-2 펠린드롬
1 parent 2e11306 commit 6b9c12a

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
function solution(str) {
2+
const newStr = str.toLowerCase();
3+
let isPalindrome = false;
4+
5+
for (let i = 0; i < newStr.length / 2; i++) {
6+
if (newStr[i] !== newStr[newStr.length - i - 1]) {
7+
isPalindrome = false;
8+
return isPalindrome;
9+
} else {
10+
isPalindrome = true;
11+
}
12+
}
13+
14+
return isPalindrome;
15+
}
16+
17+
console.log(solution('gooG')); // true
18+
console.log(solution('aba')); // true
19+
console.log(solution('abca')); // false
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
function solution(str) {
2+
const newStr = str.toLowerCase().replace(/[^a-z]/g, '');
3+
let isPalindrome = false;
4+
5+
for (let i = 0; i < newStr.length / 2; i++) {
6+
if (newStr[i] !== newStr[newStr.length - i - 1]) {
7+
isPalindrome = false;
8+
return isPalindrome;
9+
} else {
10+
isPalindrome = true;
11+
}
12+
}
13+
14+
return isPalindrome;
15+
}
16+
17+
console.log(solution('found7, time: study; Yduts; emit, 7Dnuof')); // YES
18+
console.log(solution('sungminkim')); // NO

0 commit comments

Comments
 (0)