[Programmers] 위장

Time Lapse :20min 0sec

solution.cpp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <string>
#include <vector>
#include <map>
using namespace std;

int solution(vector<vector<string>> clothes) {
map<string, int> myMAP;
map<string, int>::iterator it;
int answer = 1;
for (int i = 0; i<clothes.size(); i++) {
myMAP[clothes[i][1]] += 1;
}
for (it = myMAP.begin(); it != myMAP.end(); it++) {
answer *= it->second+1;
}
return answer-1;
}

Author: Song Hayoung
Link: https://songhayoung.github.io/2020/07/30/PS/Programmers/camouflage/
Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 4.0 unless stating additionally.