풀이과정
이 문제는 프로그래머스에 익숙해야만 풀 수 있는 문제이다.
return값이 이중 벡터이기 때문에 벡터를 만들고 벡터를 넣어주는 식으로 풀어야 한다.
#include <string>
#include <vector>
using namespace std;
vector<vector<int>> solution(vector<vector<int>> arr1, vector<vector<int>> arr2) {
vector<vector<int>> answer;
for(int i = 0; i < arr1.size(); i++){
vector<int> v;
for(int j = 0; j < arr1[i].size(); j++){
int sum = arr1[i][j] + arr2[i][j];
v.push_back(sum);
}
answer.push_back(v);
}
return answer;
}
'🍞 Problem Solving > Programmers' 카테고리의 다른 글
[프로그래머스][Level1] x만큼 간격이 있는 n개의 숫자 c++ (0) | 2022.09.03 |
---|---|
[프로그래머스][Level1] K번째수 c++ (0) | 2022.09.03 |
[프로그래머스][Level1] 핸드폰 번호 가리기 c++ (0) | 2022.09.03 |
[프로그래머스][Level1] 하샤드 수 c++ (0) | 2022.09.03 |
[프로그래머스][Level1] 폰켓몬 c++ (0) | 2022.09.03 |