https://programmers.co.kr/learn/courses/30/lessons/42578
#include <string>
#include <vector>
#include <map>
using namespace std;
int solution(vector<vector<string>> clothes) {
int answer = 1;
// 같은 의상 이름 중 하나 선택
map<string, int> kinds;
for(auto c : clothes){
string name = c[0];
string kind = c[1];
if(kinds.insert(make_pair(kind, 2)).second == false){ // 중복
kinds.find(kind)->second++;
}
}
for(map<string, int>::iterator i = kinds.begin();i != kinds.end();i++){
answer *= i->second;
}
return answer-1;
}
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
int solution(vector<vector<string>> clothes) {
int answer = 1;
unordered_map <string, int> attributes;
for(int i = 0; i < clothes.size(); i++)
attributes[clothes[i][1]]++;
for(auto it = attributes.begin(); it != attributes.end(); it++)
answer *= (it->second+1);
answer--;
return answer;
}