일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- axios
- JavaScript
- 리액트
- 항해99
- 자바
- redux-toolkit
- Get
- 매일메일
- 테코테코
- 항해플러스
- 알고리즘
- SW
- redux-saga
- programmers
- useDispatch
- 이코테
- C++
- java
- sw expert academy
- createSlice
- 코딩테스트합격자되기
- Python
- react-router
- json-server
- maeil-mail
- react
- 프로그래머스
- Algorithm
- react-redux
- redux
- Today
- Total
목록프로그래머스 (117)
Binary Journey

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(A, B){ const a = A.sort((x, y) => x - y); const b = B.sort((x, y) => y - x); return a.reduce((acc, curr, index) => acc += curr * b[index], 0); } 다른 풀이들을 보니까 모두 같은 생각이었나 보다. 아래는 가장 많은 추천을 받은 풀이다. function solution(A,B){ A.sort((a, b) => a - b) B.sort((a, b) => b - a) return A.reduce((total, val, idx) ..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges 갓택오버플로우 https://stackoverflow.com/questions/47047682/least-common-multiple-of-an-array-values-using-euclidean-algorithm Least Common Multiple of an array values using Euclidean Algorithm I want to calculate the least common multiple of an array of values, using Euclideans algorithm I am using this pseudocode implementation: found o..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(record) { let answer = []; const users = {}; const records = record.map((r) => r.split(" ")); for (const [order, id, nickName] of records) { if (nickName) users[id] = nickName; } for (const [order, id, nickName] of records) { if (order.startsWith("E")) answer.push(`${users[id]}님이 들어왔습니다.`); if (order..

지난주에 응시했는데 늦게 응시했다. 근데 그렇다고 추천을 많이 받을 만한 신박한 풀이를 제출한 것도 아니었다. 오늘로 1주차 챌린지가 끝났으니 내 풀이를 올려보겠다. 출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges 문제를 보면 등차수열의 합이다. 등차수열의 합 공식을 이용하면 된다. 100 + 200 + 300 .. -> 100 * (1 + 2 + 3 ..) 3 + 6 + 9 + 12... -> 3 * (1 + 2 + 3 ...) 결국 price * 시그마 n 으로 위 이미지에서 첫번째 식을 사용하면 된다. ** Javascript function solution(price, money, count) { const total = pric..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(n) { return `${n}`.split("").map((s) => parseInt(s)).reverse(); } 혹은 function solution(n) { return `${n}`.split("").map((s) => +s).reverse(); } 정수 내림차순으로 배치하기 문제를 응용하여 (https://binaryjourney.tistory.com/101) 작성한다면 function solution(n) { var nums = []; do{ nums.push(n % 10); n = Math.floor(n / 10); } ..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 1) 첫번째로 제출한 풀이다. function solution(n) { return parseInt(n.toString().split("").sort((a,b) => b-a).join("")); } 2) 다음 풀이도 가능하다. function solution(n) { return parseInt(n.toString().split("").sort().reverse().join("")); } sort() 메소드와 reverse() 의 경우 기본적으로 string 을 다룬다. 숫자 정렬의 경우 오름차순은 (a, b) => a - b 내림차순은 (a, b) => b- a ..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 1) 내 첫식은 이랬다 function solution(arr) { var answer = [ ...arr ]; answer.sort((a, b) => b - a).pop(); return arr.length === 1 ? [-1] : answer; } 테스트 케이스가 적어서 걸리진 않았는데 완벽한 건 아니다. 문제에서는 그냥 제일 작은 수를 제외시키라는 건데 나는 내림차순 정렬까지 한 경우라 조금 어긋난다. 보완한 식은 아래식인데 사실 내가 직접 알고 작성한 건 아니다. 그런데 제출이 아래 풀이로 되어 있다. 통과된 풀이에는 Math 안 썼는데 function s..
https://ziyuun.tistory.com/5 프로그래머스_방의개수_49190 문제 링크 조건 (0,0)에서 시작, 8방으로 이동 가능 arrows : 이동 방향을 담은 배열 (길이 1 ~ 100,000 | 범위 0 ~ 7) 방은 다른 방으로 둘러 싸여질 수 있음 접근 방법 최대 10만번 이동이 가능 => col, row 최 ziyuun.tistory.com https://coding-insider.tistory.com/entry/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4-5-%EB%B0%A9%EC%9D%98-%EA%B0%9C%EC%88%98-CC-%E2%98%85%E2%98%85%E2%98%85 [프로그래머스 5] 방의 개수 (C/C++) (..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges 이번 문제는 상당히 쉽다. ** Javascript function solution(num) { return (num % 2 === 0) ? "Even" : "Odd"; } 0 을 false로 인식하는 javascript 특성을 살려 바꾸면 function solution(num) { return (num % 2) ? "Odd" : "Even"; } 이렇게 까지 가능하다. ** Java 역시나 초간단 class Solution { public String solution(int num) { return (num % 2 == 0) ? "Even" : "Odd"; } } ** Python 간단..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 1) 내 첫번째 풀이는 이렇다 function solution(n) { let number = n; let answer = 0; while (number !== 1) { if (number % 2) { number = number * 3 + 1; } else { number /= 2; } answer++; if (answer === 500) { return -1; } } return answer; } 2) 코드를 간결하게 줄여보았다. function solution(n) { let answer = 0; while(n > 1) { n = (n % 2) ? n * 3 ..