Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/inflearn_coding_test/basic/3-1_회문문자열.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
function solution(str) {
const newStr = str.toLowerCase();
let isPalindrome = false;

for (let i = 0; i < newStr.length / 2; i++) {
if (newStr[i] !== newStr[newStr.length - i - 1]) {
isPalindrome = false;
return isPalindrome;
} else {
isPalindrome = true;
}
}

return isPalindrome;
}

console.log(solution('gooG')); // true
console.log(solution('aba')); // true
console.log(solution('abca')); // false
18 changes: 18 additions & 0 deletions src/inflearn_coding_test/basic/3-2_펠린드롬.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function solution(str) {
const newStr = str.toLowerCase().replace(/[^a-z]/g, '');
let isPalindrome = false;

for (let i = 0; i < newStr.length / 2; i++) {
if (newStr[i] !== newStr[newStr.length - i - 1]) {
isPalindrome = false;
return isPalindrome;
} else {
isPalindrome = true;
}
}

return isPalindrome;
}

console.log(solution('found7, time: study; Yduts; emit, 7Dnuof')); // YES
console.log(solution('sungminkim')); // NO