https://programmers.co.kr/learn/courses/30/lessons/42578

 

코딩테스트 연습 - 위장

 

programmers.co.kr

#include <string>
#include <vector>
#include <iostream>
#include <map>

using namespace std;

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

    map <string, int> myclothes;
    
    for (int i = 0; i < clothes.size(); i++) {
        myclothes[clothes[i][1]] += 1;
    }

    for (auto item : myclothes) {
        answer *= (item.second + 1);
    }

    return answer - 1;
}

+ Recent posts