일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- react
- 리액트
- redux-saga
- 항해99
- programmers
- sw expert academy
- 알고리즘
- 프로그래머스
- 매일메일
- maeil-mail
- redux
- JavaScript
- C++
- redux-toolkit
- 코딩테스트합격자되기
- react-redux
- react-router
- 자바
- 테코테코
- axios
- 항해플러스
- 이코테
- json-server
- Algorithm
- SW
- java
- createSlice
- useDispatch
- Python
- Get
- Today
- Total
목록Python (143)
Binary Journey
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(seoul) { return `김서방은 ${seoul.indexOf("Kim")}에 있다`; } 노마드코더가 알려준 sexy javascript backticks 사용! ** Python 파이썬은 세 가지 방법이 있다. 방법마다 특징이 있다. 1) def solution(seoul): return "김서방은 " + str(seoul.index("Kim")) + "에 있다" - 속도가 가장 빠름 - 메모리 가장 적게 차지함 2) def solution(seoul): return ('김서방은 %d에 있다' %seoul.index('Kim..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 1) 프로그래머스를 알고 거의 첫번째로 푼 문제가 아닐까 싶다. 그 당시 javascript 메소드 활용을 잘 못하였다. function solution(n) { var answer = ''; for (var i=1; i
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 초간단! function solution(s) { return Number(s); } 근데 굳이 Number 쓰지 않고도 숫자 변환을 할 수 있다. function solution(s) { return parseInt(s); } function solution(s) { return s * 1; } function solution(s) { return +s; } function solution(s) { return s / 1; } 네 가지 풀이 중에서는 +s 를 사용하는 게 가장 빠르다. ** Python def solution(s): return int(s) ** ..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 1) 처음에 제출했던 풀이 function solution(n) { let answer = 0; for (let i = 1; i (n % (index + 1)) ? 0 : index + 1) .reduce((acc, curr) => acc += curr, 0); } function solution(n) { return new Array(n).fill(0) .reduce((acc, curr, index) => acc += (n % (index + 1)) ? 0 : index + 1, 0); } 하지만 for 문 돌리는 게 가장 빠르다. 풀이 중 추천 1등은 재귀의 신..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 1) 맨 처음 제출한 풀이는 이랬다. 프로그래머스 접한 지 얼마 안돼서 푼 문제여서 혼자 되게 뿌듯했던 기억이 있다 지금 보면 약간 흑역사지만 function solution(s) { var [ ...strings ] = s.split(" "); var answers = []; for (var string of strings) { var temp = ""; for (var i=0; i Array.from(word).reduce((acc, curr, index) => acc += (index % 2) ? curr.toLowerCase() : curr.toUpperCa..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript 1) 맨 처음 제출한 코드는 이렇다. function solution(n) { let answer = 0; const string = `${n}`; for (var i=0; i acc += parseInt(curr), 0); } 3) 숫자 n 을 string 으로 만들지 않는 풀이는 다음과 같다. function solution(n) { let answer = 0; while(n > 0) { answer += n % 10; n = Math.floor(n / 10); } return answer; } ** Java 1) 숫자로만 자릿수를 구해서 합산하는 방법 impo..
출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(s) { const c = s.split(" ").map((n) => +n); return `${Math.min.apply(null, c)} ${Math.max.apply(null, c)}`; } 다른 풀이를 보니 숫자로 변환할 필요가 없었다. 다음은 추천을 가장 많이 받은 풀이다. function solution(s) { const arr = s.split(' '); return Math.min(...arr)+' '+Math.max(...arr); } + 풀이 추가 (2021.12.06) function solution(s) { c..
출처: 프로그래머스 코딩 테스트 연습, 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..
지난주에 응시했는데 늦게 응시했다. 근데 그렇다고 추천을 많이 받을 만한 신박한 풀이를 제출한 것도 아니었다. 오늘로 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..