프로그래머스 120896 한 번만 등장한 문자

1 개요[ | ]

프로그래머스 120896 한 번만 등장한 문자

2 C++[ | ]

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

string solution(string s) {
    map<char, int> m;
    for(char ch: s) {
        m[ch]++;
    }
    string answer = "";
    for(auto el: m) {
        if(el.second == 1) {
            answer += el.first;
        }
    }
    return answer;
}
#include <string>
#include <vector>
#include <map>
using namespace std;

string solution(string s) {
    map<char, int> m;
    for(char ch: s) {
        if(m.find(ch) == m.end()) {
            m[ch] = 1;
        } else {
            m[ch]++;
        }
    }
    string answer = "";
    for (auto const& [k, v]: m) {
        if(v == 1) {
            answer += k;
        }
    }
    return answer;
}