From cb0f1f0a4fa2e31aba0d23f3535138ad79b4af28 Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Thu, 26 Oct 2023 12:47:04 +0900 Subject: [PATCH 01/15] =?UTF-8?q?Lv=201.=20K=EB=B2=88=EC=A7=B8=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\353\217\204\354\234\244/week3/Knum.js" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "\353\217\204\354\234\244/week3/Knum.js" diff --git "a/\353\217\204\354\234\244/week3/Knum.js" "b/\353\217\204\354\234\244/week3/Knum.js" new file mode 100644 index 0000000..4ca5f98 --- /dev/null +++ "b/\353\217\204\354\234\244/week3/Knum.js" @@ -0,0 +1,14 @@ +//Lv 1. K번째수 - 정렬 +function solution(array, commands) { + let res = [], + tmp = []; + let start = 0, + end = 0; + commands.forEach((elm) => { + start = elm[0] - 1; + end = elm[1] - 1; + tmp = array.slice(start, end + 1).sort((a, b) => a - b); + res.push(tmp[elm[2] - 1]); + }); + return res; +} From 8cbf9aa86f9abd7df765436cad317cd960282a39 Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Fri, 27 Oct 2023 22:54:35 +0900 Subject: [PATCH 02/15] =?UTF-8?q?Lv=202.=20=EC=B5=9C=EC=86=9F=EA=B0=92=20?= =?UTF-8?q?=EB=A7=8C=EB=93=A4=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\353\217\204\354\234\244/week3/[Lv 2] MakeMinimum.js" | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 "\353\217\204\354\234\244/week3/[Lv 2] MakeMinimum.js" diff --git "a/\353\217\204\354\234\244/week3/[Lv 2] MakeMinimum.js" "b/\353\217\204\354\234\244/week3/[Lv 2] MakeMinimum.js" new file mode 100644 index 0000000..a7a84d6 --- /dev/null +++ "b/\353\217\204\354\234\244/week3/[Lv 2] MakeMinimum.js" @@ -0,0 +1,10 @@ +// Lv 2. 최솟값 만들기 - 연습문제 +function solution(A, B) { + let answer = 0; + A.sort((a, b) => b - a); + B.sort((a, b) => a - b); + for (let i = 0; i < A.length; i++) { + answer += A[i] * B[i]; + } + return answer; +} From 0f6c9c8b905c4c5e6098eac4635ce8a3d41506d2 Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Fri, 27 Oct 2023 22:55:19 +0900 Subject: [PATCH 03/15] =?UTF-8?q?K=EB=B2=88=EC=A7=B8=20=EC=88=98=20?= =?UTF-8?q?=ED=8C=8C=EC=9D=BC=EC=9D=B4=EB=A6=84=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Knum.js" => "\353\217\204\354\234\244/week3/[Lv 1]Knum.js" | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename "\353\217\204\354\234\244/week3/Knum.js" => "\353\217\204\354\234\244/week3/[Lv 1]Knum.js" (100%) diff --git "a/\353\217\204\354\234\244/week3/Knum.js" "b/\353\217\204\354\234\244/week3/[Lv 1]Knum.js" similarity index 100% rename from "\353\217\204\354\234\244/week3/Knum.js" rename to "\353\217\204\354\234\244/week3/[Lv 1]Knum.js" From d2bc0687cc7920f211eb61b19ce750795b9b225b Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Sun, 29 Oct 2023 16:30:47 +0900 Subject: [PATCH 04/15] =?UTF-8?q?Lv=201.=20=EA=B0=80=EC=9E=A5=20=EA=B0=80?= =?UTF-8?q?=EA=B9=8C=EC=9A=B4=20=EA=B0=99=EC=9D=80=20=EA=B8=80=EC=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week3/[Lv 1]AdjacentSameLetter.js" | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 "\353\217\204\354\234\244/week3/[Lv 1]AdjacentSameLetter.js" diff --git "a/\353\217\204\354\234\244/week3/[Lv 1]AdjacentSameLetter.js" "b/\353\217\204\354\234\244/week3/[Lv 1]AdjacentSameLetter.js" new file mode 100644 index 0000000..2b86a5f --- /dev/null +++ "b/\353\217\204\354\234\244/week3/[Lv 1]AdjacentSameLetter.js" @@ -0,0 +1,16 @@ +//Lv 1. 가장 가까운 같은 글자 - 연습문제 +function solution(s) { + const letters = [], + answer = []; + + s.split("").forEach((elm, idx) => { + if (!letters.includes(elm)) { + answer.push(-1); + letters.push(elm); + } else { + answer.push(idx - letters.lastIndexOf(elm)); + letters.push(elm); + } + }); + return answer; +} From a4af664734ba930fb7fcdf3ead4a17d68274adfd Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Mon, 30 Oct 2023 17:36:29 +0900 Subject: [PATCH 05/15] =?UTF-8?q?Lv=201.=202016=EB=85=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- "\353\217\204\354\234\244/week4/[Lv 1] 2016.js" | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 "\353\217\204\354\234\244/week4/[Lv 1] 2016.js" diff --git "a/\353\217\204\354\234\244/week4/[Lv 1] 2016.js" "b/\353\217\204\354\234\244/week4/[Lv 1] 2016.js" new file mode 100644 index 0000000..50530ed --- /dev/null +++ "b/\353\217\204\354\234\244/week4/[Lv 1] 2016.js" @@ -0,0 +1,12 @@ +//Lv 1. 2016년 - 연습문제 +function solution(a, b) { + const days = ["SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"]; + const lastDay = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]; + let dayCnt = 0; + let daysIdx = 5; //1월 1일이 금요일이기 때문에 금요일 idx부터 시작 + + for (let i = 1; i <= a; i++) { + i === a ? (dayCnt += b) : (dayCnt += lastDay[i - 1]); + } + return days[(dayCnt + daysIdx - 1) % 7]; +} From 3adf375e0530dc5ce7457f1c52b7cec6c98ae88e Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Tue, 31 Oct 2023 17:48:04 +0900 Subject: [PATCH 06/15] =?UTF-8?q?Lv=202.=20=EC=9D=B4=EC=A7=84=20=EB=B3=80?= =?UTF-8?q?=ED=99=98=20=EB=B0=98=EB=B3=B5=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week4/[Lv 2]BinaryConversion.js" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "\353\217\204\354\234\244/week4/[Lv 2]BinaryConversion.js" diff --git "a/\353\217\204\354\234\244/week4/[Lv 2]BinaryConversion.js" "b/\353\217\204\354\234\244/week4/[Lv 2]BinaryConversion.js" new file mode 100644 index 0000000..23c2d77 --- /dev/null +++ "b/\353\217\204\354\234\244/week4/[Lv 2]BinaryConversion.js" @@ -0,0 +1,15 @@ +//Lv 2. 이진 변환 반복하기 - 월간 코드 챌린지 시즌1 +function solution(s) { + let len = 0, + removed = 0, + times = 0; + + while (s.length > 1) { + len = s.length; + s = s.split("0").join(""); + removed += len - s.length; + times++; + s = s.length.toString(2); + } + return [times, removed]; +} From 2f5250983fb36cb126a8bbbafb678d6e04930d78 Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Tue, 31 Oct 2023 21:09:51 +0900 Subject: [PATCH 07/15] =?UTF-8?q?Lv=201.=20[1=EC=B0=A8]=20=EB=B9=84?= =?UTF-8?q?=EB=B0=80=EC=A7=80=EB=8F=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week4/[Lv 1] SecretMap.js" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "\353\217\204\354\234\244/week4/[Lv 1] SecretMap.js" diff --git "a/\353\217\204\354\234\244/week4/[Lv 1] SecretMap.js" "b/\353\217\204\354\234\244/week4/[Lv 1] SecretMap.js" new file mode 100644 index 0000000..2a424af --- /dev/null +++ "b/\353\217\204\354\234\244/week4/[Lv 1] SecretMap.js" @@ -0,0 +1,24 @@ +/* Lv 1. [1차] 비밀지도 - 2018 KAKAO BLIND RECRUITMENT +배열 속 주어진 수를 모두 2진수로 변환 +변환한 2진수 중 모두 0일 때만 0 -> 공백 (하나라도 1이면 벽'#' 출력) +*/ +function solution(n, arr1, arr2) { + let binary1 = [], + binary2 = []; + let answer = ""; + let res = []; + arr1.forEach((elm) => binary1.push(elm.toString(2).padStart(n, 0))); + arr2.forEach((elm) => binary2.push(elm.toString(2).padStart(n, 0))); + for (let i = 0; i < n; i++) { + answer = ""; + for (let j = 0; j < n; j++) { + if (binary1[i][j] === "0" && binary2[i][j] === "0") { + answer += " "; + } else { + answer += "#"; + } + } + res.push(answer); + } + return res; +} From d29603cae954fa74ed189e143093f28662fac1eb Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Fri, 3 Nov 2023 18:49:48 +0900 Subject: [PATCH 08/15] =?UTF-8?q?Lv=201.=20=EA=B3=BC=EC=9D=BC=EC=9E=A5?= =?UTF-8?q?=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week4/[Lv 1] Fruits.js" | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 "\353\217\204\354\234\244/week4/[Lv 1] Fruits.js" diff --git "a/\353\217\204\354\234\244/week4/[Lv 1] Fruits.js" "b/\353\217\204\354\234\244/week4/[Lv 1] Fruits.js" new file mode 100644 index 0000000..f0fe76d --- /dev/null +++ "b/\353\217\204\354\234\244/week4/[Lv 1] Fruits.js" @@ -0,0 +1,20 @@ +// Lv 1. 과일장수 - 연습문제 +function solution(k, m, score) { + let box = []; + let price = 0, + answer = 0; + + if (score.length < m) { + return 0; + } + + score.sort((a, b) => a - b); + + while (score.length >= m) { + box = score.splice(score.length - m, m); + price = m * box[0]; + answer += price; + } + + return answer; +} From 5d835cbf0fac46320f11653a4088ce63acbb832f Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Fri, 3 Nov 2023 20:40:29 +0900 Subject: [PATCH 09/15] =?UTF-8?q?Lv=202.=20=EC=88=AB=EC=9E=90=EC=9D=98=20?= =?UTF-8?q?=ED=91=9C=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week4/[Lv 2] ExpressNumber.js" | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 "\353\217\204\354\234\244/week4/[Lv 2] ExpressNumber.js" diff --git "a/\353\217\204\354\234\244/week4/[Lv 2] ExpressNumber.js" "b/\353\217\204\354\234\244/week4/[Lv 2] ExpressNumber.js" new file mode 100644 index 0000000..b1ba26b --- /dev/null +++ "b/\353\217\204\354\234\244/week4/[Lv 2] ExpressNumber.js" @@ -0,0 +1,25 @@ +// Lv 2. 숫자의 표현 - 연습문제 + +// 나의 풀이 (효율성 겁사 통과 X) +function solution(n) { + let cnt = 0; + for (let i = 1; i <= n; i++) { + let sum = 0; + for (let j = i; j <= n; j++) { + sum += j; + if (sum >= n && sum === n) { + cnt++; + } + } + } + return cnt; +} + +/* 참고할 풀이 : 주어진 자연수를 연속되는 자연수들의 합으로 표현할 수 있는 방법의 수는 주어진 자연수의 약수 중에서 홀수인 수의 개수와 같다 */ +function solution(n) { + let cnt = 0; + for (let i = 1; i <= n; i++) { + n % i === 0 && i % 2 === 1 ? cnt++ : null; + } + return cnt; +} From cbdfc9ffab1b9fc7e6274fa5493098e58d2b230c Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Sun, 5 Nov 2023 14:11:41 +0900 Subject: [PATCH 10/15] =?UTF-8?q?Lv=201.=20=EB=AC=B8=EC=9E=90=EC=97=B4=20?= =?UTF-8?q?=EB=82=98=EB=88=84=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week4/[Lv 1] SplitString.js" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "\353\217\204\354\234\244/week4/[Lv 1] SplitString.js" diff --git "a/\353\217\204\354\234\244/week4/[Lv 1] SplitString.js" "b/\353\217\204\354\234\244/week4/[Lv 1] SplitString.js" new file mode 100644 index 0000000..d671835 --- /dev/null +++ "b/\353\217\204\354\234\244/week4/[Lv 1] SplitString.js" @@ -0,0 +1,24 @@ +// Lv 1. 문자열 나누기 - 연습문제 +function solution(s) { + let curChar = ""; + let same = 0, + diff = 0, + cnt = 0; + + for (let c of s) { + curChar === "" ? (curChar = c) : null; + curChar === c ? same++ : diff++; + + if (same === diff) { + cnt++; + same = diff = 0; + curChar = ""; + } + } + + if (curChar.length > 0) { + cnt++; + } + + return cnt; +} From bc0814f543ed05b2f93d53f240510f086fa6a809 Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Thu, 9 Nov 2023 20:27:05 +0900 Subject: [PATCH 11/15] =?UTF-8?q?Lv=201.=20=EB=AA=A8=EC=9D=98=EA=B3=A0?= =?UTF-8?q?=EC=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week5/[Lv 1] Test.js" | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 "\353\217\204\354\234\244/week5/[Lv 1] Test.js" diff --git "a/\353\217\204\354\234\244/week5/[Lv 1] Test.js" "b/\353\217\204\354\234\244/week5/[Lv 1] Test.js" new file mode 100644 index 0000000..d6b0747 --- /dev/null +++ "b/\353\217\204\354\234\244/week5/[Lv 1] Test.js" @@ -0,0 +1,23 @@ +// Lv 1. 모의고사 - 완전탐색 +function solution(answers) { + const sol1 = [1, 2, 3, 4, 5], + sol2 = [2, 1, 2, 3, 2, 4, 2, 5], + sol3 = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]; + let cnt1 = 0, + cnt2 = 0, + cnt3 = 0; + const answer = []; + + answers.forEach((elm, idx) => { + if (sol1[idx % sol1.length] === elm) cnt1++; + if (sol2[idx % sol2.length] === elm) cnt2++; + if (sol3[idx % sol3.length] === elm) cnt3++; + }); + + const max = Math.max(cnt1, cnt2, cnt3); + if (cnt1 === max) answer.push(1); + if (cnt2 === max) answer.push(2); + if (cnt3 === max) answer.push(3); + + return answer; +} From 7440ab910a3567b91009364ef386ad535b1a4b39 Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Sat, 11 Nov 2023 00:11:45 +0900 Subject: [PATCH 12/15] =?UTF-8?q?Lv=201.=20=EC=B6=94=EC=96=B5=20=EC=A0=90?= =?UTF-8?q?=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week5/[Lv 1] MemoryScore.js" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 "\353\217\204\354\234\244/week5/[Lv 1] MemoryScore.js" diff --git "a/\353\217\204\354\234\244/week5/[Lv 1] MemoryScore.js" "b/\353\217\204\354\234\244/week5/[Lv 1] MemoryScore.js" new file mode 100644 index 0000000..0d2a3ad --- /dev/null +++ "b/\353\217\204\354\234\244/week5/[Lv 1] MemoryScore.js" @@ -0,0 +1,15 @@ +// Lv 1. 추억 점수 - 연습문제 +function solution(name, yearning, photo) { + let missingScore = []; + let tmpScr = 0; + for (let i = 0; i < photo.length; i++) { + tmpScr = 0; + for (let j = 0; j < photo[i].length; j++) { + if (name.includes(photo[i][j])) { + tmpScr += yearning[name.indexOf(photo[i][j])]; + } + } + missingScore.push(tmpScr); + } + return missingScore; +} From 50e3bc6a8078b72d3874b764d4795a1fbf401b52 Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Sat, 11 Nov 2023 00:34:09 +0900 Subject: [PATCH 13/15] =?UTF-8?q?[Lv=202]=20=EB=8B=A4=EC=9D=8C=20=ED=81=B0?= =?UTF-8?q?=20=EC=88=AB=EC=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week5/[Lv 2] NextBigNumber.js" | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 "\353\217\204\354\234\244/week5/[Lv 2] NextBigNumber.js" diff --git "a/\353\217\204\354\234\244/week5/[Lv 2] NextBigNumber.js" "b/\353\217\204\354\234\244/week5/[Lv 2] NextBigNumber.js" new file mode 100644 index 0000000..fb322cd --- /dev/null +++ "b/\353\217\204\354\234\244/week5/[Lv 2] NextBigNumber.js" @@ -0,0 +1,22 @@ +// Lv 2. 다음 큰 숫자 - 연습문제 +function solution(n) { + const findCnt = (num) => { + return num + .toString(2) + .split("") + .filter((elm) => elm === "1").length; + }; + + let start = n + 1; + let oneCnt = 0; + + while (true) { + oneCnt = findCnt(start); + if (oneCnt === findCnt(n)) { + break; + } + start++; + } + + return start; +} From 367c052d6dd7f038fb9bcf5563817cffdd14e577 Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Sun, 12 Nov 2023 01:00:14 +0900 Subject: [PATCH 14/15] =?UTF-8?q?[Lv=202]=20=ED=94=BC=EB=B3=B4=EB=82=98?= =?UTF-8?q?=EC=B9=98=20=EC=88=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week5/[Lv 2] Fibonacci.js" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "\353\217\204\354\234\244/week5/[Lv 2] Fibonacci.js" diff --git "a/\353\217\204\354\234\244/week5/[Lv 2] Fibonacci.js" "b/\353\217\204\354\234\244/week5/[Lv 2] Fibonacci.js" new file mode 100644 index 0000000..b86ff59 --- /dev/null +++ "b/\353\217\204\354\234\244/week5/[Lv 2] Fibonacci.js" @@ -0,0 +1,13 @@ +// Lv 2. 피보나치 수 - 연습문제 +function solution(n) { + let add1 = 0, + add2 = 1, + sum = 0, + mod = 0; + for (let i = 2; i <= n; i++) { + sum = (add1 + add2) % 1234567; + add1 = add2; + add2 = sum; + } + return sum; +} From d6ffbfcf150c433cdd1ed2769ca3a7be85f197c5 Mon Sep 17 00:00:00 2001 From: Doyun Lee Date: Sun, 12 Nov 2023 01:02:56 +0900 Subject: [PATCH 15/15] =?UTF-8?q?[Lv=201]=20=EB=91=98=EB=A7=8C=EC=9D=98=20?= =?UTF-8?q?=EC=95=94=ED=98=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../week5/[Lv 1] SecretCode.js" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "\353\217\204\354\234\244/week5/[Lv 1] SecretCode.js" diff --git "a/\353\217\204\354\234\244/week5/[Lv 1] SecretCode.js" "b/\353\217\204\354\234\244/week5/[Lv 1] SecretCode.js" new file mode 100644 index 0000000..518e86d --- /dev/null +++ "b/\353\217\204\354\234\244/week5/[Lv 1] SecretCode.js" @@ -0,0 +1,13 @@ +// Lv 1. 둘만의 암호 - 연습문제 +function solution(s, skip, index) { + let answer = ""; + const alphArr = Array(26) + .fill() + .map((v, i) => String.fromCharCode(i + 97)) + .filter((elm) => !skip.includes(elm)); + s.split("").forEach((elm, idx) => { + let newIdx = (alphArr.indexOf(elm) + index) % alphArr.length; + answer += alphArr[newIdx]; + }); + return answer; +}