되게 쉬웠다.
장착하지 않음을 하나의 옵션으로 생각하여 풀면 된다.
#include <string>
#include <vector>
#include <map>
using namespace std;
int solution(vector<vector<string>> clothes) {
int answer = 1;
map<string, int> hash;
for (int i = 0; i < clothes.size(); i++)
hash[clothes[i][1]]++;
for (map<string, int>::iterator it = hash.begin(); it != hash.end(); it++)
answer *= (it->second) + 1;
return --answer;
}
'Coding_Test 연습 > Programmers' 카테고리의 다른 글
[프로그래머스] (C++) LV2 H-Index (0) | 2022.05.28 |
---|---|
[프로그래머스] (C++) LV2 다리를 지나는 트럭 (0) | 2022.05.26 |
[프로그래머스] (C++) LV2 배달 (0) | 2022.05.25 |
[프로그래머스] (C++) LV2 괄호 회전하기 (0) | 2022.05.25 |
[프로그래머스] (C++) LV2 예상 대진표 (0) | 2022.05.24 |