애니리뷰

맵 공부

두원공대88학번뚜뚜 2021. 2. 1. 02:42
#include <string>
#include <vector>
#include <map>

using namespace std;

int solution(vector<vector<string>> clothes) {
    int answer=1;
    map<string, int> m;

    for(int i=0; i<clothes.size(); i++) {
        if(m.find(clothes[i][1])==m.end()) {
            m.insert(make_pair(clothes[i][1], 1));
        }
        else {
            m[clothes[i][1]]++;
        }
    }
    
    for(auto i=m.begin(); i!=m.end(); i++) {
        answer *=(i->second+1);   
    }
//    return v.size();
    return answer-1;
}