공부/C++

[C++] 프로그래머스 의상

굴러다니다니 2025. 4. 4. 22:50

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

 

프로그래머스

SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프

programmers.co.kr

#include <string>
#include <vector>
#include <iostream>
#include <unordered_map>

using namespace std;

int solution(vector<vector<string>> clothes) {
    int answer = 1;
    unordered_map<string, int> type;
    for(int i = 0; i < clothes.size(); i++){
        type[clothes[i][1]]++;
    }
    for(auto a : type){
        answer *= a.second+1;
    }
    return --answer;
}
728x90
반응형