diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..41fb5ee Binary files /dev/null and b/.DS_Store differ diff --git a/lumen/.DS_Store b/lumen/.DS_Store new file mode 100644 index 0000000..70b90ae Binary files /dev/null and b/lumen/.DS_Store differ diff --git "a/lumen/week1/01_\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\260/\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\260.js" "b/lumen/week1/01_\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\260/\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\260.js" new file mode 100644 index 0000000..1219e33 --- /dev/null +++ "b/lumen/week1/01_\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\260/\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\260.js" @@ -0,0 +1,10 @@ +const arr = [-1, 3, 2, 5]; + +function solution(arr){ + arr.sort((a, b) => a - b); + return arr; +} + +const result = solution(arr); + +console.log(result); diff --git "a/lumen/week1/02_\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\260/\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\2602.js" "b/lumen/week1/02_\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\260/\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\2602.js" new file mode 100644 index 0000000..33f5042 --- /dev/null +++ "b/lumen/week1/02_\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\260/\353\260\260\354\227\264_\354\240\225\353\240\254\355\225\230\352\270\2602.js" @@ -0,0 +1,10 @@ +const arr = [-1, -1, 2, 4]; + +function solution(arr) { + const uniqueArray = new Set(arr); + const filteredArray = [...uniqueArray].sort((a, b) => b - a); + + return filteredArray; +} + +console.log(solution(arr)); diff --git "a/lumen/week1/03_\353\221\220_\352\260\234_\353\275\221\354\225\204\354\204\234_\353\215\224\355\225\230\352\270\260/03_\353\221\220_\352\260\234_\353\275\221\354\225\204\354\204\234_\353\215\224\355\225\230\352\270\260.js" "b/lumen/week1/03_\353\221\220_\352\260\234_\353\275\221\354\225\204\354\204\234_\353\215\224\355\225\230\352\270\260/03_\353\221\220_\352\260\234_\353\275\221\354\225\204\354\204\234_\353\215\224\355\225\230\352\270\260.js" new file mode 100644 index 0000000..42a6f9c --- /dev/null +++ "b/lumen/week1/03_\353\221\220_\352\260\234_\353\275\221\354\225\204\354\204\234_\353\215\224\355\225\230\352\270\260/03_\353\221\220_\352\260\234_\353\275\221\354\225\204\354\204\234_\353\215\224\355\225\230\352\270\260.js" @@ -0,0 +1,28 @@ +// 의사 코드 작성 +// 1. 배열의 첫번째 원소를 뽑는다. +// 2. 배열의 두번째 원소를 뽑는다. +// 3. 뽑은 두 원소를 더한다. +/* +4. 처음에 뽑은 원소와 두번째 뽑은 원소를 제외한 나머지 원소를 더하고 이 행동을 나머지 배열의 끝 원소까지 N-1번 반복한다. +5. + + +*/ +// 2. 뽑은 두 원소를 더한다. +// 3. 결과를 출력한다. + +const arr = [1, 2, 3, 4, 5, 6]; +let result = []; + +for (let i = 0; i < arr.length; i++) { + for (let j = 1; j < arr.length; j++) { + result.push(arr[i] + arr[j]); + } +} + +result.sort((a, b) => a - b); + +const result2 = new Set(result) + +console.log(result2); + diff --git "a/lumen/week1/04_\353\252\250\354\235\230\352\263\240\354\202\254/04_\353\252\250\354\235\230\352\263\240\354\202\254.js" "b/lumen/week1/04_\353\252\250\354\235\230\352\263\240\354\202\254/04_\353\252\250\354\235\230\352\263\240\354\202\254.js" new file mode 100644 index 0000000..e349912 --- /dev/null +++ "b/lumen/week1/04_\353\252\250\354\235\230\352\263\240\354\202\254/04_\353\252\250\354\235\230\352\263\240\354\202\254.js" @@ -0,0 +1,15 @@ +function solution(answer) { + // 1번 수포자 12345 + // 2번 수포자 2123425 + // 3번 수포자 3311224455 + + const patterns = [ + [1, 2, 3, 4, 5], + [2, 1, 2, 3, 4, 2, 5], + [3, 3, 1, 1, 2, 2, 4, 4, 5, 5], + ]; + + const scores = [0, 0, 0]; + + // +} \ No newline at end of file diff --git a/lumen/week1/index.js b/lumen/week1/index.js index e69de29..c79a5f1 100644 --- a/lumen/week1/index.js +++ b/lumen/week1/index.js @@ -0,0 +1,3 @@ +const arr1 = new Array(6); +const arr2 = [...arr1].map((_, i) => i + 1); +console.log(arr2); diff --git "a/lumen/week2/[PSG_12973]\354\247\235\354\247\200\354\226\264 \354\240\234\352\261\260\355\225\230\352\270\260/\354\212\244\355\203\235_\352\270\260\353\263\270\354\230\210\354\240\234.js" "b/lumen/week2/[PSG_12973]\354\247\235\354\247\200\354\226\264 \354\240\234\352\261\260\355\225\230\352\270\260/\354\212\244\355\203\235_\352\270\260\353\263\270\354\230\210\354\240\234.js" new file mode 100644 index 0000000..a8ed34e --- /dev/null +++ "b/lumen/week2/[PSG_12973]\354\247\235\354\247\200\354\226\264 \354\240\234\352\261\260\355\225\230\352\270\260/\354\212\244\355\203\235_\352\270\260\353\263\270\354\230\210\354\240\234.js" @@ -0,0 +1,17 @@ +const stack = []; +const maxSize = 10; + +function push(stack, item) { + stack.push(item); + console.log('아이템이 추가 되었습니다.'); +} + +function pop(stack) { + if (stack.length === 0) { + console.log('스택이 비어 있습니다.'); + return null; + } + else { + return stack.pop(); + } +} \ No newline at end of file diff --git "a/lumen/week2/[PSG_12973]\354\247\235\354\247\200\354\226\264 \354\240\234\352\261\260\355\225\230\352\270\260/\354\247\235\354\247\200\354\226\264_\354\240\234\352\261\260\355\225\230\352\270\260.js" "b/lumen/week2/[PSG_12973]\354\247\235\354\247\200\354\226\264 \354\240\234\352\261\260\355\225\230\352\270\260/\354\247\235\354\247\200\354\226\264_\354\240\234\352\261\260\355\225\230\352\270\260.js" new file mode 100644 index 0000000..4b3fb52 --- /dev/null +++ "b/lumen/week2/[PSG_12973]\354\247\235\354\247\200\354\226\264 \354\240\234\352\261\260\355\225\230\352\270\260/\354\247\235\354\247\200\354\226\264_\354\240\234\352\261\260\355\225\230\352\270\260.js" @@ -0,0 +1,16 @@ +function solution(inputString) { + const stack = []; + + for (let i = 0; i < inputString.length; i++) { + // 스택의 최상위 값과 문자열의 현재 값과 비교한다. + if (stack.length > 0 && stack[stack.length - 1] === inputString[i]) { + stack.pop(); + // 비교해서 현재 문자와 스택의 최상위 문자열이 맨 위 문자 제거 + } else { + stack.push(inputString[i]); + // 스택에 현재 문자 추가 + } + } + + return stack.length === 0 ? 1 : 0; +} \ No newline at end of file diff --git "a/lumen/week2/[PSG_12973]\354\247\235\354\247\200\354\226\264 \354\240\234\352\261\260\355\225\230\352\270\260/\354\247\235\354\247\200\354\226\264_\354\240\234\352\261\260\355\225\230\352\270\260_N^2\355\222\200\354\235\264.js" "b/lumen/week2/[PSG_12973]\354\247\235\354\247\200\354\226\264 \354\240\234\352\261\260\355\225\230\352\270\260/\354\247\235\354\247\200\354\226\264_\354\240\234\352\261\260\355\225\230\352\270\260_N^2\355\222\200\354\235\264.js" new file mode 100644 index 0000000..b43a183 --- /dev/null +++ "b/lumen/week2/[PSG_12973]\354\247\235\354\247\200\354\226\264 \354\240\234\352\261\260\355\225\230\352\270\260/\354\247\235\354\247\200\354\226\264_\354\240\234\352\261\260\355\225\230\352\270\260_N^2\355\222\200\354\235\264.js" @@ -0,0 +1,33 @@ +function solution(s) { + const n = s.length; + // n이 홀수면 절대 모두 제거할 수 없음 + if (n % 2 !== 0) return 0; + + // dp[n][n] 배열 생성 (공간 복잡도 O(n^2)) + const dp = Array.from({ length: n }, () => Array(n).fill(false)); + + // 구간의 길이(len)를 2부터 n까지 2씩 증가시키며 확인 + for (let len = 2; len <= n; len += 2) { + for (let i = 0; i <= n - len; i++) { + let j = i + len - 1; + + // 1. 양 끝 문자가 같고 내부가 다 지워지는 경우 + if (s[i] === s[j]) { + if (len === 2 || dp[i + 1][j - 1]) { + dp[i][j] = true; + continue; + } + } + + // 2. 중간 지점 k를 기준으로 두 구간으로 나뉘어 각각 지워지는 경우 + for (let k = i + 1; k < j; k += 2) { + if (dp[i][k] && dp[k + 1][j]) { + dp[i][j] = true; + break; + } + } + } + } + + return dp[0][n - 1] ? 1 : 0; +} \ No newline at end of file diff --git "a/lumen/week2/[PSG_42584]\354\243\274\354\213\235\352\260\200\352\262\251/\354\243\274\354\213\235_\352\260\200\352\262\251.js" "b/lumen/week2/[PSG_42584]\354\243\274\354\213\235\352\260\200\352\262\251/\354\243\274\354\213\235_\352\260\200\352\262\251.js" new file mode 100644 index 0000000..47cbf6e --- /dev/null +++ "b/lumen/week2/[PSG_42584]\354\243\274\354\213\235\352\260\200\352\262\251/\354\243\274\354\213\235_\352\260\200\352\262\251.js" @@ -0,0 +1,6 @@ +function solution(prices){ + const answer = new Array.fill(prices.length); + + const stack = [0]; + +} \ No newline at end of file diff --git "a/lumen/week2/[PSG_64061]\355\201\254\353\240\210\354\235\270 \354\235\270\355\230\225 \353\275\221\352\270\260 \352\262\214\354\236\204/\355\201\254\353\240\210\354\235\270_\354\235\270\355\230\225_\353\275\221\352\270\260_\352\262\214\354\236\204.js" "b/lumen/week2/[PSG_64061]\355\201\254\353\240\210\354\235\270 \354\235\270\355\230\225 \353\275\221\352\270\260 \352\262\214\354\236\204/\355\201\254\353\240\210\354\235\270_\354\235\270\355\230\225_\353\275\221\352\270\260_\352\262\214\354\236\204.js" new file mode 100644 index 0000000..4f4ead9 --- /dev/null +++ "b/lumen/week2/[PSG_64061]\355\201\254\353\240\210\354\235\270 \354\235\270\355\230\225 \353\275\221\352\270\260 \352\262\214\354\236\204/\355\201\254\353\240\210\354\235\270_\354\235\270\355\230\225_\353\275\221\352\270\260_\352\262\214\354\236\204.js" @@ -0,0 +1,29 @@ +function solution(board, moves) { + let answer = 0; + const basket = []; + + for (let col of moves) { + col -= 1; // 인덱스는 0부터 + + // 해당 열에서 위에서부터 인형 찾기 + for (let row = 0; row < board.length; row++) { + const doll = board[row][col]; + + if (doll !== 0) { + board[row][col] = 0; // 칸 비우기 + + // 바구니 맨 위와 같으면 pop + if (basket.length > 0 && basket[basket.length - 1] === doll) { + basket.pop(); + answer += 2; + } else { + basket.push(doll); + } + + break; + } + } + } + + return answer; +} \ No newline at end of file diff --git "a/lumen/week3/[PSG]\352\270\260\353\212\245 \352\260\234\353\260\234/\352\270\260\353\212\245_\352\260\234\353\260\234.js" "b/lumen/week3/[PSG]\352\270\260\353\212\245 \352\260\234\353\260\234/\352\270\260\353\212\245_\352\260\234\353\260\234.js" new file mode 100644 index 0000000..2b60057 --- /dev/null +++ "b/lumen/week3/[PSG]\352\270\260\353\212\245 \352\260\234\353\260\234/\352\270\260\353\212\245_\352\260\234\353\260\234.js" @@ -0,0 +1,23 @@ +function solution(progresses, speeds) { + const answer = []; + + + while (progresses.length > 0) { + // 하나라도 100이 될 때까지 더하기 + while (progresses[0] < 100) { + progresses = progresses.map((p, i) => p + speeds[i]); + } + + // 앞에서부터 100 이상인 것들 count + let count = 0; + while (progresses.length > 0 && progresses[0] >= 100) { + progresses.shift(); + speeds.shift(); + count++; + } + + answer.push(count); + } + + return answer +} \ No newline at end of file diff --git "a/lumen/week3/\354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234/\354\232\224\354\204\270\355\221\270\354\212\244_\353\254\270\354\240\234.js" "b/lumen/week3/\354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234/\354\232\224\354\204\270\355\221\270\354\212\244_\353\254\270\354\240\234.js" new file mode 100644 index 0000000..1fb6dda --- /dev/null +++ "b/lumen/week3/\354\232\224\354\204\270\355\221\270\354\212\244 \353\254\270\354\240\234/\354\232\224\354\204\270\355\221\270\354\212\244_\353\254\270\354\240\234.js" @@ -0,0 +1,20 @@ +function solution(N, K) { + const queue = []; + + for (let i = 1; i <= N; i++) { + queue.push(i); + } + + while (queue.length > 1) { + // 앞의 K-1명을 뒤로 보냄 + for (let i = 0; i < K - 1; i++) { + const frontPerson = queue.shift(); // 앞사람 꺼내기 + queue.push(frontPerson); // 다시 뒤에 넣기 + } + + // 이제 맨 앞 사람이 K번째 사람이므로 제거 + queue.shift(); + } + + return queue[0]; +} \ No newline at end of file