프로그래머스
1. Python
from collections import Counter
def solution(participant, completion):
answer = ''
p = Counter(participant)
c = Counter(completion)
for i in participant:
if(p[i] != c[i]):
answer += i
break
return answer
2. C++
#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])
return participant[i];
}
return participant[participant.size() - 1];
}
3. JavaScript
function solution(participant, completion) {
participant.sort();
completion.sort();
for(let i = 0; i < completion.length; i++){
if(participant[i] != completion[i])
return participant[i]
}
return participant[participant.length -1]
}