일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- javascript
- BFS
- 가천대
- 소켓
- socket
- HTTP 완벽 가이드
- TCP
- Node.js
- 프로그래머스 레벨 2
- 수학
- dp
- Crawling
- 자바스크립트
- 백준
- dfs
- 알고리즘
- Nestjs
- 그래프
- 타입스크립트
- 레벨 1
- 타입 챌린지
- ip
- typescript
- Algorithm
- 쉬운 문제
- 문자열
- 프로그래머스
- HTTP
- 크롤링
- type challenge
- Today
- Total
목록프로그래머스 (67)
kakasoo
// 프로그래머스 레벨2 예상 대진표를 풀었습니다. // 둘 씩 잘라서 계속 붙게 하면 언젠가 만나겠거니, 라는 생각으로 풀었습니다. const getOneRound = (arr) => { const answer = []; for (let i = 0; i { let humans = new Array(n).fill(0); humans[a - 1] = 1; humans[b - 1] = 1; let count = 0; loop1: while (true) { count++; humans = getOneRound(huma..
// 프로그래머스 레벨 2 [카카오 인턴] 수식 최대화 const getPriority = () => { const operator = ["+", "-", "*"]; const priority = []; let visited; let answer; const dfs = (start) => { visited[start] = true; answer.push(operator[start]); if (answer.length === 3) { priority.push([...answer]); } for (let i = 0; i < operator.length; i++) { if (!visited[i]) { visited[i] = true; dfs(i); visited[i] = false; answer.pop(); ..
// 프로그래머스 레벨1 신규 아이디 추천을 풀었습니다. const firstRule = (str) => str.toLowerCase(); const secondRule = (str) => str .split("") .filter((el) => { const charCode = el.charCodeAt(); const aCode = "a".charCodeAt(); const zCode = "z".charCodeAt(); const zeroCode = "0".charCodeAt(); const nineCode = "9".charCodeAt(); if ( (zeroCode (str.length ? str : "a"); const sixthRule = (str) => { const next = str.leng..
// 프로그래머스 레벨 1 폰켓몬을 풀었습니다. const solution = (nums) => { const chance = parseInt(nums.length / 2); const max = Array.from(new Set(nums)).length; return max >= chance ? chance : max; };
// 프로그래머스 레벨 1 음양 더하기를 풀었습니다. const solution = (absolutes, signs) => { let sum = 0; for (let i = 0; i < absolutes.length; i++) { sum += signs[i] ? absolutes[i] : -absolutes[i]; } return sum; };
// 프로그래머스 레벨 1 약수의 개수와 덧셈을 풀었습니다. const countDiv = (n) => { const div = new Set(); for (let i = 1; i { let sum = 0; for (let i = left; i
// 프로그래머스 레벨 1 3진법 뒤집기를 풀었습니다. const solution = (n) => parseInt(n.toString(3).split("").reverse().join(""), 3);
// 프로그래머스 level1 예산을 풀었습니다. function solution(d, budget) { d = d.sort((a, b) => 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 소수 만들기를 풀었습니다. const solution = (nums) => { const answer = []; const visited = Array(nums.length).fill(false); let count = 0; const sumOfVisited = () => { let sum = 0; for (let i = 0; i { if (visited.filter((el) => el).length === 3) { answer.push(sumOfVisited()); return;..
// 프로그래머스 레벨2 멀쩡한 사각형을 풀었습니다. // 나는 이걸 그래프라고 생각하여, 기울기를 이용해 구하려고 시도했다. // 시간초과가 나와서 결국 못풀던 문제인데, 오늘 찾아보니 최대공약수를 이용하는 문제였다. const gcd = (w, h) => { if (w % h === 0) { return h; } return gcd(h, w % h); }; const solution = (w, h) => { const gcdVal = gcd(w, h); return w * h - (w + h - gcdVal); };
// 프로그래머스 레벨2 구명보트를 풀었습니다. const isEmpty = (stack) => (stack.length ? false : true); function solution(people, limit) { const sortedStack = people.sort((a, b) => a - b); let count = 0; while (!isEmpty(sortedStack)) { let sum = sortedStack.pop(); while (sortedStack.length && sum + sortedStack[0]
// 프로그래머스 레벨2 큰수 만들기를 풀었습니다. // 그리디하지 않은 방식만 생각나서 한참을 고생한 문제입니다. 코드는 간결하지만 어려웠습니다. const solution = (number, k) => { const stack = []; for (let i = 0; i 0 && stack[stack.length - 1] < now) { stack.pop(); k--; } stack.push(now); } return stack.slice(0, stack.length - k).join(""); };