반응형
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
string solution(vector<string> participant, vector<string> completion) {
string answer = ""; //결과를 저장할 변수
multiset<string>s; //중복된 key값 저장가능하며, 오름차순으로 정렬되는 multiset 선언
for (int i = 0; i < participant.size(); i++) //참여자들을 multiset에 insert
s.insert(participant[i]);
for (auto it = completion.begin();it != completion.end();it++)
{
s.erase(s.find(*it)); //multiset에서 완주한 선수를 찾은 후 삭제
}
answer = *(s.begin()); //multiset에 남은 값은 완주하지 못한 선수
return answer;
}
반응형
'Programming > Programmers' 카테고리의 다른 글
프로그래머스 체육복 Level 1 [c++] (0) | 2022.02.20 |
---|---|
프로그래머스 가장큰수 [c++] (0) | 2022.02.17 |
프로그래머스 이중우선순위큐 Level2 [c++] (0) | 2022.02.13 |
프로그래머스 주식가격 Level2 [c++] (0) | 2022.02.11 |
프로그래머스 기능개발 Level2 [c++] (0) | 2022.02.10 |