728x90
반응형
문제
https://school.programmers.co.kr/learn/courses/30/lessons/176963
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
풀이와 코드
사진에 인물이 있을 경우에 인물의 그리움 점수를 더했다.
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
vector<int> solution(vector<string> name, vector<int> yearning, vector<vector<string>> photo) {
vector<int> answer;
for(int i=0; i<photo.size(); i++){
int score = 0;
for(int j=0; j<name.size(); j++){
if(find(photo[i].begin(), photo[i].end(), name[j]) != photo[i].end()){
score += yearning[j];
}
}
answer.push_back(score);
}
return answer;
}
728x90
반응형
'코딩테스트 > 프로그래머스' 카테고리의 다른 글
[프로그래머스] 카드 뭉치 (1) | 2023.10.26 |
---|---|
[프로그래머스] 명예의 전당(1) (2) | 2023.10.26 |
[프로그래머스] 콜라 문제 (1) | 2023.08.11 |
[프로그래머스] 가장 가까운 같은 글자 (1) | 2023.08.07 |
[프로그래머스] 푸드 파이트 대회 (2) | 2023.08.01 |