#include <string>
#include <vector>
#include <map>
using namespace std;
 
int solution(vector<vector<string>> clothes) 
{
    map<stringint> m;  // 옷 종류 개수 저장할 맵
    vector<string> name; // 옷 종류 이름 저장할 벡터
    
    for(int i = 0; i < clothes.size(); i++)
    {   
        // 옷 종류 이름 저장한적 없으면
        if(m[clothes[i][1]] == 0)
        {
            name.push_back(clothes[i][1]);
        }
        
        m[clothes[i][1]]++;
    }
    
    // (옷 1번 개수+안입었을때) * (옷 2번 개수+안입었을때) * (옷 3번 개수+안입었을때) .... -1(아무것도 안입었을때)
    int result = 1;
    for(int i = 0; i < name.size(); i++)
    {
        result *= (m[name[i]]+1);
    }
    result -= 1;
    
    return result;
}
cs

+ Recent posts