728x90
- 문제
https://programmers.co.kr/learn/courses/30/lessons/12950
- 풀이법 ( 알고리즘 )
벡터끼리의 연산. 처음이라 낯설었다. 이외에는 그저 손코딩한 걸 구현하면 된다.
- 풀이 - C++
#include <string>
#include <vector>
using namespace std;
vector<vector<int>> solution(vector<vector<int>> arr1, vector<vector<int>> arr2) {
vector<vector<int>> answer(arr1.size(), vector<int>(0, 0));;
for(int i = 0; i < arr1.size(); i++)
{
for(int j = 0; j < arr2[i].size(); j++)
{
answer[i].push_back(arr1[i][j] + arr2[i][j]);
}
}
return answer;
}
728x90
'PS > 프로그래머스' 카테고리의 다른 글
[ 프로그래머스 ] Lv 1. 스택/큐 같은 숫자는 싫어 - (C++/C) (0) | 2022.08.31 |
---|---|
[ 프로그래머스 ] Lv1 월간 코드 챌린지 시즌 3 : 없는 숫자 더하기 (C++/C) (0) | 2022.03.12 |
[ 프로그래머스 ] Lv 1 연습문제 : x만큼 간격이 있는 n개의 숫자 - ( C++/C ) (0) | 2022.03.10 |
[ 프로그래머스 ] Lv1 연습문제 : 직사각형 별찍기 - ( C++/C ) (0) | 2022.03.10 |
[ 프로그래머스 ] Lv1 완전탐색 : 모의고사 ( C++/C ) (0) | 2022.03.10 |