#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] != completion[i]) { answer = participant[i]; return answer; } } // 끝까지 했는데 못찾은 경우, participant의 맨 마지막이 정답 answer = participant[participant.size()-1]; return answer; } | cs |
'Programmers > Level 1' 카테고리의 다른 글
[프로그래머스 1] 가운데 글자 가져오기 (C/C++) (0) | 2019.10.17 |
---|---|
[프로그래머스 1] 2016년 (C/C++) (0) | 2019.10.17 |
[프로그래머스 1] K번째수 (C/C++) (0) | 2019.10.17 |
[프로그래머스 1] 체육복 (C/C++) (0) | 2019.10.16 |
[프로그래머스 1] 모의고사 (C/C++) (0) | 2019.10.16 |