완주하지 못한 선수
문제 링크 : (https://programmers.co.kr/learn/courses/30/lessons/42576)
풀이
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
string solution(vector<string> participant, vector<string> completion) {
int csize =(int)completion.size();
int psize =(int)participant.size();
sort(participant.begin(),participant.end());
sort(completion.begin(),completion.end());
while(1){
if(participant[--psize] == completion[--csize])
continue;
else{
return participant[psize];
}
}
}