일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
- ip
- 프로그래머스
- typescript
- Crawling
- 타입스크립트
- 그래프
- 알고리즘
- Nestjs
- BFS
- dfs
- 프로그래머스 레벨 2
- dp
- 크롤링
- 레벨 1
- Node.js
- TCP
- 가천대
- 타입 챌린지
- 수학
- HTTP
- Algorithm
- 쉬운 문제
- javascript
- type challenge
- 백준
- 소켓
- 문자열
- 자바스크립트
- socket
- HTTP 완벽 가이드
- Today
- Total
목록프로그래밍 (478)
kakasoo
//프로그래머스 레벨1 예산을 풀었습니다. function solution(d, budget) { let sum = 0; let count = 0; d.sort((o1, o2) => o1 - o2).some((el, i) => { if (sum + el a - b); const DP = new Array(d.length).fill(0); if (budget - d[0] >= 0) { DP[0] = 1; budget -= d[0]; } for (let i = 1; i = 0) { DP[i] = Math.max(DP[i -1] + 1, DP[i]); budget -= d[i]; } } return Math.max(...DP); } 정렬해서..
// 프로그래머스 레벨1 직사각형 별찍기를 풀었습니다. process.stdin.setEncoding("utf8"); process.stdin.on("data", (data) => { const n = data.split(" "); const a = Number(n[0]), b = Number(n[1]); for (let i = 0; i < b; i++) { for (let j = 0; j < a; j++) { process.stdout.write("*"); } console.log(); } }); 다 더해주기만 하면 되는 간단한 문제.
// 프로그래머스 레벨1 x만큼 간격이 있는 n개의 숫자를 풀었습니다. function solution(x, n) { let arr = [x]; let temp = x; for (let i = 0; i < n - 1; i++) { temp += x; arr.push(temp); } return arr; } 다 더해주기만 하면 되는 간단한 문제.
// 프로그래머스 레벨1 행렬의 덧셈을 풀었습니다. function solution(arr1, arr2) { return arr1.map((el, i) => el.map((n, j) => (n += arr2[i][j]))); } 다 더해주기만 하면 되는 간단한 문제.
// 프로그래머스 레벨1 핸드폰 번호 가리기를 풀었습니다. function solution(phone_number) { let a, b, c, d, e; let arr = ([a, b, c, d, ...e] = phone_number.split("").reverse()); return [e.map((el) => "*").join(""), d, c, b, a].join(""); } 구조분해할당과 나머지 연산자를 이용하면 쉽게 가능해진다.
// 프로그래머스 레벨1 하샤드 수를 풀었습니다. function solution(x) { return ( x % String(x) .split("") .map((el) => Number(el)) .reduce((acc, cur) => acc + cur) === 0 ); } 자기 자신의 각 자릿수의 합으로 나누어 떨어지는 수.
// 프로그래머스 레벨1 평균구하기를 풀었습니다. function solution(arr) { return arr.reduce((acc, cur) => acc + cur) / arr.length; }
// 프로그래머스 레벨1 최대공약수와 최소공배수를 풀었습니다. function solution(n, m) { if (n > m) [n, m] = [m, n]; const arr = []; for (let i = 2; i acc * cur); const max = min === 1 ? n * m : min * n * m; return [min, max]; } 이제는 gcd를 구하지, 저렇게 구하지 않는다. 재귀적 방법이 더 쉽기 때문이다.
// 프로그래머스 레벨1 짝수와 홀수를 풀었습니다. function solution(num) { if (num % 2 === 0) return "Even"; return "Odd"; } const solution = (num) => ["Even", "Odd"][num]; 이렇게도 가능하긴 하다. 작년 9월에 풀어서 코드가 C++ 같다.
// 프로그래머스 level1 제일 작은 수 제거하기를 풀었습니다. function solution(arr) { let min = 9875654321; if (arr.length === 1) return [-1]; arr.map((el, i) => { if (el < min) min = el; return el; }); arr.splice(arr.indexOf(min), 1); return arr; }
// 프로그래머스 레벨1 정수 내림차순으로 배치하기를 풀었습니다. function solution(n) { return Number(String(n).split("").sort().reverse().join("")); }