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

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(a, b) { const answer = a.reduce((acc, curr, index, arr) => acc + curr * b[index], 0); return answer; } ** Python def solution(a, b): answer = 0 for i in range(len(a)): answer += a[i] * b[i] return answer 추천 1등 풀이 아름답다 아름다와 def solution(a, b): return sum([x*y for x, y in zip(a,b)]) ** Java class Solut..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function isPrimeNumber(total) { for (let i = 2; i acc + isPrimeNumber(curr), 0); }

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(participant, completion) { participant.sort(); completion.sort(); for(var i = 0; i < participant.length; i++) { if (participant[i] !== completion[i]) { return participant[i]; } } } ** Python def solution(participant, completion): participant.sort() completion.sort() for i in range(len(completion)): i..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(array, commands) { var answer = []; for (const command of commands) { const sliced = array.slice(command[0]-1, command[1]); sliced.sort(function(a,b){return a-b}); answer.push(sliced[command[2]-1]); } return answer; } ** Python def solution(array, commands): answer = [] for i, j, k in commands: answe..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(answers) { let answer = []; const first = [1, 2, 3, 4, 5]; const second = [2, 1, 2, 3, 2, 4, 2, 5]; const third = [3, 3, 1, 1, 2, 2, 4, 4, 5, 5]; const supoja1 = answers.filter((answer, index) => answer === first[index % first.length]).length; const supoja2 = answers.filter((answer, index) => answer ..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Python (+2) def solution(n): for i in range(2, n + 1): if n % i == 1: return i return n ** Java class Solution { public int solution(int n) { int answer = n; for (int i = 2; i < n; i++) { if (n % i == 1) answer = Math.min(answer, i); } return answer; } } ** Javascript function solution(n) { for (let i = 2; i < n; i++) { if (n % ..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(nums) { const result = [ ...new Set(nums)]; return result.length < nums.length / 2 ? result.length : nums.length / 2; } 이렇게 해도 된다 function solution(nums) { const result = [ ...new Set(nums)]; return Math.min(result.length, nums.length / 2); }

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges 테스트케이스 5, 12에서 계속 통과가 안돼서 힘들었다. 질문하기에서 찾아보니 잃어버렸는데 여유분도 가지고 있는 학생이 존재하는 경우가 있다고 한다. 그래서 filter를 해줘야 했음 ** Javascript 오랜만에 자바스크립트로 6점 받음 function solution(n, lost, reserve) { let realLost = lost.filter((item) => !reserve.includes(item)); let realReserve = reserve.filter((item) => !lost.includes(item)); let answer = n - realLost.leng..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges 오름차순 정렬 후 누적합계가 budget 값 이하인 것만 추출 ** Javascript function solution(d, budget) { d.sort((a, b) => a - b); while(d.reduce((a, b) => a + b, 0) > budget) d.pop(); return d.length; } 효율성이 더 나은 건 아래 function solution(d, budget) { d.sort((a, b) => a - b); let total = 0; for (let i = 0; i budge..

출처: 프로그래머스 코딩 테스트 연습, https://programmers.co.kr/learn/challenges ** Javascript function solution(left, right) { let answer = 0; let numbers = range(left, right, 1); console.log(numbers) for (const number of numbers) { let count = 0; for (let i = 1; i Array.from({ length: (stop - start) / step + 1}, (_, i) => start + (i * step)); 감탄만 나왔던 소스 function solution(left, right) { let answer = 0; for (le..