https://school.programmers.co.kr/learn/courses/30/lessons/42576

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

#include <string>
#include <vector>
#include<unordered_map>
using namespace std;

string solution(vector<string> participant, vector<string> completion) 
{
    string answer = "";
    unordered_map<string, int> map;
    for(string s : participant)
    {
        if(map.empty() == false && map.find(s) != map.end())
            map[s]++;
        else
            map.insert({s,1});
    }

    for (string s : completion)
    {
        if(map.find(s) != map.end())
            map[s]--;
    }
    
    for(pair<string, int> i : map)
    {
        if(i.second != 0)
        {
            answer = i.first;
            break;
        }
    }
    return answer;
}

'코딩 태스트 > 문제풀이' 카테고리의 다른 글

영어 끝말잇기  (0) 2025.04.24
단어 변환  (0) 2025.04.02
게임 맵 최단거리  (0) 2025.04.02
연산자 끼워넣기-14888  (0) 2025.03.19
코딩테스트 책 - 모의고사  (0) 2025.03.17