코딩테스트/프로그래머스
[Level 1][C++] 완주하지 못한 선수
MJ.Lee
2024. 10. 1. 12:41
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
string solution(vector<string> participant, vector<string> completion) {
string answer;
sort(participant.begin(), participant.end());
sort(completion.begin(), completion.end());
for(int i=0; i<completion.size(); i++)
if(participant[i].compare(completion[i]) != 0)
{
answer = participant[i];
return answer;
}
return participant[participant.size()-1];
}