코딩테스트/프로그래머스

프로그래머스 문제풀이 - 완주하지 못한 선수 (해시)

글로벌디노 2020. 10. 21. 22:27

프로그래머스 문제풀이

코딩테스트 연습 > 해시 > 완주하지 못한 선수

programmers.co.kr/learn/courses/30/lessons/42576

 

 

C++ 코드

#include <string>
#include <vector>
#include <map>

using namespace std;

string solution(vector<string> participant, vector<string> completion) 
{
    map<string, int> strMap;
    for (auto name : completion)
        ++strMap[name];

    for (auto name : participant)
        if (--strMap[name] < 0)
            return name;
}