본문 바로가기
반응형

풀이23

[프로그래머스] 없는 숫자 더하기 C++ Code 2022.08.08 - [Coding Test/Python] - [프로그래머스] 없는 숫자 더하기 Python Code 2022.08.08 - [Coding Test/Go] - [프로그래머스] 없는 숫자 더하기 Go Code 저번 python, go 포스트에 이어서 프로그래머스 레벨 1 없는 숫자 더하기를 C++로 풀어보겠다. 문제 문제는 간단하게 이해할 수 있다. [0-9]의 범위에서 numbers에 없는 숫자를 찾아서 더하면 된다. 구현 방식 이번에도 0-9의 총합 45에서 numbers의 총합을 빼도록 구현했다. 코드 #include #include using namespace std; int solution(vector numbers) { int sum = 0; for (int i = 0 ; i .. 2022. 8. 8.
[프로그래머스] 내적 JavaScript Code 2022.07.29 - [Coding Test/Go] - [프로그래머스] 내적 Go Code 2022.07.29 - [Coding Test/Python] - [프로그래머스] 내적 Python Code 2022.07.29 - [Coding Test/C++] - [프로그래머스] 내적 C++ Code 프로그래머스 내적을 JS로 풀어보겠다. 문제 Code function solution(a, b) { var answer = 0; for(var i=0; i acc += a[i] * b[i], 0); } JS reduce reduce는 4개의 인자를 가진다. 1. acc : 누산기 2. cur : 현재 값 3. idx : 현재 idx 4. src : 원본 배열 작동 방식은 reduce 함수의 반환값이 acc에 계속.. 2022. 7. 29.
[프로그래머스] 내적 Go Code 2022.07.29 - [Coding Test/Python] - [프로그래머스] 내적 Python Code 2022.07.29 - [Coding Test/C++] - [프로그래머스] 내적 C++ Code 이번엔 Go로 풀어보겠다. 문제 Code func solution(a []int, b []int) (answer int) { for i := range a { answer += a[i] * b[i] } return } 2022. 7. 29.
반응형