GaGe

[프로그래머스] 위장 - C++ 본문

알고리즘/[2021] 프로그래머스

[프로그래머스] 위장 - C++

Sorrel 2021. 5. 31. 01:59
#include <string>
#include <vector>
#include <map>

using namespace std;

int solution(vector<vector<string>> clothes) {
    map<string, int> strMap;
    for(vector<string> elem : clothes){
        strMap[elem[1]]+=1;
    }
    int result =1;
    map<string, int> ::iterator iter;
    for(iter = strMap.begin(); iter!=strMap.end(); iter++){
        result *= iter->second+1;
    }
    result--;
    
    return result;
}
Comments