전체 글

전체 글

    Programmers / Level 2 / 메뉴 리뉴얼 / JS

    프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr /** * num개로 이루어진 가능한 모든 조합을 반환하는 함수 * * @param {string[]} order * @param {number[]} num 조합을 이룰 order의 개수 * @returns */ function getCombination(order, num) { let result = []; if (num === 1) return order.map((el) => [el]); order.forEach((fixed, idx) => { let rest = order.slice..

    백준 / 누적 합 / 11659번 / 구간 합 구하기 4 / JS

    11659번: 구간 합 구하기 4 첫째 줄에 수의 개수 N과 합을 구해야 하는 횟수 M이 주어진다. 둘째 줄에는 N개의 수가 주어진다. 수는 1,000보다 작거나 같은 자연수이다. 셋째 줄부터 M개의 줄에는 합을 구해야 하는 구간 i와 j www.acmicpc.net const fs = require('fs'); const filePath = process.platform === 'linux' ? '/dev/stdin' : '../input.txt'; // const filePath = process.platform === 'linux' ? '/dev/stdin' : 'BOJ/input.txt'; const input = fs.readFileSync(filePath).toString..

    Programmers / Level 2 / 피로도 / JS

    프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(k, dungeons) { let visited = Array.from({ length: dungeons.length }, () => false); let clearedCnt = 0; const DFS = (k, currentCnt) => { clearedCnt = Math.max(currentCnt, clearedCnt); for(let i=0; i= minRequiredFatigue && !visited[i]) { visited[i] = true; DF..

    Programmers / Level 0 / 다음에 올 숫자 / JS

    function isArithmeticSequence(common) { if(common[1] - common[0] === common[2] - common[1]) { return true; } else { return false; } } function isGeometricSequence(common) { if(common[1] / common[0] === common[2] / common[1]) { return true; } else { return false; } } function solution(common) { if(isArithmeticSequence(common)) { return common.at(-1) + common[1] - common[0]; } else if(..

    Programmers / Level 0 / 최빈값 구하기 / JS

    프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr function solution(array) { let answer = 0; let numberCountObj = {}; array.forEach((el) => { numberCountObj[el] = numberCountObj[el] + 1 || 1; }); let max = Math.max(...Object.values(numberCountObj)); let cnt = 0; Object.entries(numberCountObj).forEach(el => { if(el[1] === ma..

    TS Compiler

    Watch 만약 app.ts를 컴파일 할 때 tsc app.ts -w 혹은 tsc app.ts --watch를 입력한다면 관찰 모드로 진입하게 된다. 그러면 저장이 될 때 마다 디스크에 저장이되고, 컴파일을 자동적으로 다시 하게 된다. 이처럼 관찰 모드는 좋은 기능이지만, 파일을 구체적으로 지정해야 한다는 번거로운 단점이 있어 규모가 큰 프로젝트에서는 잘 사용하지 않는다. 전체 프로젝트 컴파일 / 다수의 파일 특정 파일을 지정하지 않고 tsc --init 을 하면 이 커맨드가 실행되는 폴더의 모든 항목을 TS에게 알려주게 된다. 그러면 tsconfig.json 파일이 생기게 되고, 설정들을 관리할 수 있다. 그리고 나서 tsc를 입력하게 되면 폴더 내의 모든 .ts 파일들을 컴파일하게 된다. 또한 모두 ..