diff --git "a/src/inflearn_coding_test/basic/3-1_\355\232\214\353\254\270\353\254\270\354\236\220\354\227\264.js" "b/src/inflearn_coding_test/basic/3-1_\355\232\214\353\254\270\353\254\270\354\236\220\354\227\264.js" new file mode 100644 index 0000000..b895ce7 --- /dev/null +++ "b/src/inflearn_coding_test/basic/3-1_\355\232\214\353\254\270\353\254\270\354\236\220\354\227\264.js" @@ -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 diff --git "a/src/inflearn_coding_test/basic/3-2_\355\216\240\353\246\260\353\223\234\353\241\254.js" "b/src/inflearn_coding_test/basic/3-2_\355\216\240\353\246\260\353\223\234\353\241\254.js" new file mode 100644 index 0000000..fc5755a --- /dev/null +++ "b/src/inflearn_coding_test/basic/3-2_\355\216\240\353\246\260\353\223\234\353\241\254.js" @@ -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