From 9cdbb557d97dcbb99706047861642d257aedc3c3 Mon Sep 17 00:00:00 2001 From: HA-SEUNG-JEONG Date: Sat, 10 Dec 2022 10:22:11 +0900 Subject: [PATCH 1/8] =?UTF-8?q?[PGS]=20=ED=96=89=EB=A0=AC=EC=9D=98?= =?UTF-8?q?=EA=B3=B1=EC=85=89/level2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...\240\254\354\235\230\352\263\261\354\205\210.js" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "\354\243\274\353\247\220/haseung/Week18/\355\226\211\353\240\254\354\235\230\352\263\261\354\205\210.js" diff --git "a/\354\243\274\353\247\220/haseung/Week18/\355\226\211\353\240\254\354\235\230\352\263\261\354\205\210.js" "b/\354\243\274\353\247\220/haseung/Week18/\355\226\211\353\240\254\354\235\230\352\263\261\354\205\210.js" new file mode 100644 index 00000000..eb1b2ac1 --- /dev/null +++ "b/\354\243\274\353\247\220/haseung/Week18/\355\226\211\353\240\254\354\235\230\352\263\261\354\205\210.js" @@ -0,0 +1,13 @@ +function solution(arr1, arr2) { + const [row, col] = [arr1.length, arr2[0].length]; //3 2 + let answer = new Array(row); + for (let i = 0; i < row; i++) { + answer[i] = new Array(col); + } + for (let i = 0; i < row; i++) { + for (let j = 0; j < col; j++) { + answer[i][j] = arr1[i].reduce((acc, val, index) => acc + val * arr2[index][j], 0); + } + } + return answer; +} From b4c3989e3acda7932cf1971cda0d9ee32026e02e Mon Sep 17 00:00:00 2001 From: HA-SEUNG-JEONG Date: Sat, 10 Dec 2022 10:22:24 +0900 Subject: [PATCH 2/8] =?UTF-8?q?[PGS]=20=ED=8A=9C=ED=94=8C/level2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Week18/\355\212\234\355\224\214.js" | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 "\354\243\274\353\247\220/haseung/Week18/\355\212\234\355\224\214.js" diff --git "a/\354\243\274\353\247\220/haseung/Week18/\355\212\234\355\224\214.js" "b/\354\243\274\353\247\220/haseung/Week18/\355\212\234\355\224\214.js" new file mode 100644 index 00000000..42e04231 --- /dev/null +++ "b/\354\243\274\353\247\220/haseung/Week18/\355\212\234\355\224\214.js" @@ -0,0 +1,27 @@ +function solution(s) { + const answer = []; + // console.log(s.slice(2, s.length - 2).split("},{")) //[ '2', '2,1', '2,1,3', '2,1,3,4' ] + // console.log(s.slice(2, s.length - 2).split("},{").map(str=>str.split(',').map(Number).)) //[ [ 2 ], [ 2, 1 ], [ 2, 1, 3 ], [ 2, 1, 3, 4 ] ] + // s.slice(2, s.length - 2) + // .split("},{") + // .map((str) => str.split(",").map(Number)) + // .sort((a, b) => a.length - b.length) + // .flatMap((arr) => { + // arr.map((v) => { + // if (!answer.includes(v)) answer.push(v); + // }); + // }); + // return answer; + + const splited = s.slice(2, s.length - 2).split("},{"); + const sortedArrayAfterSplit = splited + .map((str) => str.split(",").map(Number)) + .sort((a, b) => a.length - b.length); + + sortedArrayAfterSplit.flatMap((arr) => { + arr.map((value) => { + if (!answer.includes(value)) answer.push(value); + }); + }); + return answer; +} From ca182b5b7115c9c2d6734e11509ab1ebc5566bfa Mon Sep 17 00:00:00 2001 From: HA-SEUNG-JEONG Date: Sat, 10 Dec 2022 10:22:38 +0900 Subject: [PATCH 3/8] [PGS} H-index/level2 --- "\354\243\274\353\247\220/haseung/Week18/H-index.js" | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 "\354\243\274\353\247\220/haseung/Week18/H-index.js" diff --git "a/\354\243\274\353\247\220/haseung/Week18/H-index.js" "b/\354\243\274\353\247\220/haseung/Week18/H-index.js" new file mode 100644 index 00000000..e7636354 --- /dev/null +++ "b/\354\243\274\353\247\220/haseung/Week18/H-index.js" @@ -0,0 +1,12 @@ +function solution(citations) { + citations.sort((a, b) => b - a); + + let answers = 0; + for (let i = 0; i < citations.length; i++) { + if (i < citations[i]) { + answers++; + } + } + + return answers; +} From b0ab9414340c5fa129657f6bd07ef31d63af7f73 Mon Sep 17 00:00:00 2001 From: HA-SEUNG-JEONG Date: Sat, 10 Dec 2022 10:23:32 +0900 Subject: [PATCH 4/8] [LeetCode] 1689 minPartitions --- "\354\243\274\353\247\220/haseung/Week18/leetcode/1689.js" | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 "\354\243\274\353\247\220/haseung/Week18/leetcode/1689.js" diff --git "a/\354\243\274\353\247\220/haseung/Week18/leetcode/1689.js" "b/\354\243\274\353\247\220/haseung/Week18/leetcode/1689.js" new file mode 100644 index 00000000..d3379e9c --- /dev/null +++ "b/\354\243\274\353\247\220/haseung/Week18/leetcode/1689.js" @@ -0,0 +1,7 @@ +/** + * @param {string} n + * @return {number} + */ +var minPartitions = function (n) { + return [...n].reduce((acc, cur) => Math.max(acc, cur)); +}; From 94c65e4379f086aeb0b87ecea11f943f0d1cb47e Mon Sep 17 00:00:00 2001 From: HA-SEUNG-JEONG Date: Sat, 10 Dec 2022 10:23:49 +0900 Subject: [PATCH 5/8] =?UTF-8?q?[PGS]=20=EA=B4=84=ED=98=B8=20=ED=9A=8C?= =?UTF-8?q?=EC=A0=84=ED=95=98=EA=B8=B0/level2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...14\354\240\204\355\225\230\352\270\260.js" | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 "\354\243\274\353\247\220/haseung/Week19/\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" diff --git "a/\354\243\274\353\247\220/haseung/Week19/\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" "b/\354\243\274\353\247\220/haseung/Week19/\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" new file mode 100644 index 00000000..050e66b2 --- /dev/null +++ "b/\354\243\274\353\247\220/haseung/Week19/\352\264\204\355\230\270\355\232\214\354\240\204\355\225\230\352\270\260.js" @@ -0,0 +1,24 @@ +function solution(s) { + const pair = { "}": "{", "]": "[", ")": "(" }; + + const arr = s.split(""); + let result = 0; + const isValid = (arr) => { + const stack = []; + for (let i = 0; i < arr.length; i++) { + const element = arr[i]; + if (pair[element] === undefined) stack.push(element); + else { + if (stack[stack.length - 1] !== pair[element]) return false; + stack.pop(); + } + } + if (stack.length) return false; + return true; + }; + for (let i = 0; i < s.length; i++) { + if (isValid(arr)) result++; + arr.push(arr.shift()); + } + return result; +} From d05fb0e56c08ca687831a9902d9b25172be5e081 Mon Sep 17 00:00:00 2001 From: HA-SEUNG-JEONG Date: Sat, 10 Dec 2022 10:24:01 +0900 Subject: [PATCH 6/8] =?UTF-8?q?[PGS]=20=EA=B8=B0=EB=8A=A5=EA=B0=9C?= =?UTF-8?q?=EB=B0=9C/level2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...60\353\212\245\352\260\234\353\260\234.js" | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 "\354\243\274\353\247\220/haseung/Week19/\352\270\260\353\212\245\352\260\234\353\260\234.js" diff --git "a/\354\243\274\353\247\220/haseung/Week19/\352\270\260\353\212\245\352\260\234\353\260\234.js" "b/\354\243\274\353\247\220/haseung/Week19/\352\270\260\353\212\245\352\260\234\353\260\234.js" new file mode 100644 index 00000000..2eba5a27 --- /dev/null +++ "b/\354\243\274\353\247\220/haseung/Week19/\352\270\260\353\212\245\352\260\234\353\260\234.js" @@ -0,0 +1,21 @@ +function solution(progresses, speeds) { + let answer = []; + let days = 1; + let cnt = 0; + let progress = 0; + + while (progresses[0]) { + progress = progresses[0] + speeds[0] * days; + if (progress >= 100) { + cnt++; + progresses.shift(); + speeds.shift(); + } else { + if (cnt > 0) answer.push(cnt); + days++; + cnt = 0; + } + } + answer.push(cnt); + return answer; +} From 9b0f2ec13be0fb255dcb8f6401750fe430dba820 Mon Sep 17 00:00:00 2001 From: HA-SEUNG-JEONG Date: Sat, 10 Dec 2022 10:24:12 +0900 Subject: [PATCH 7/8] =?UTF-8?q?[PGS}=20=EC=9C=84=EC=9E=A5/level2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../haseung/Week19/\354\234\204\354\236\245.js" | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 "\354\243\274\353\247\220/haseung/Week19/\354\234\204\354\236\245.js" diff --git "a/\354\243\274\353\247\220/haseung/Week19/\354\234\204\354\236\245.js" "b/\354\243\274\353\247\220/haseung/Week19/\354\234\204\354\236\245.js" new file mode 100644 index 00000000..da378f95 --- /dev/null +++ "b/\354\243\274\353\247\220/haseung/Week19/\354\234\204\354\236\245.js" @@ -0,0 +1,13 @@ +function solution(clothes) { + let answer = 1; + let obj = {}; + for (let i = 0; i < clothes.length; i++) { + obj[clothes[i][1]] = (obj[clothes[i][1]] || 1) + 1; + } + + for (let key in obj) { + answer *= obj[key]; + } + + return answer - 1; +} From 6d385d303a71eb9d9a0f5a2cf1be5d1ae2228b20 Mon Sep 17 00:00:00 2001 From: HA-SEUNG-JEONG Date: Sat, 10 Dec 2022 10:24:34 +0900 Subject: [PATCH 8/8] [LeetCode] 1476 Subrectangle Queries --- "\354\243\274\353\247\220/haseung/Week19/leetcode/1476.js" | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 "\354\243\274\353\247\220/haseung/Week19/leetcode/1476.js" diff --git "a/\354\243\274\353\247\220/haseung/Week19/leetcode/1476.js" "b/\354\243\274\353\247\220/haseung/Week19/leetcode/1476.js" new file mode 100644 index 00000000..e69de29b