2차배열 인덱스 확인
개수 곱하기는 init이 0이면 안됨
종류1 - 의상1, 의상2,
종류2 - 의상3
3*2 -1 = 5
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
int solution(vector<vector<string>> clothes) {
int ans = 1;
unordered_map<string, int> umap;
for(int i=0;i<clothes.size();i++){
umap[clothes[i][1]]++;
}
for(auto ele : umap){
ans *= (ele.second+1);
}
return ans-1;
}
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
unordered_map<string,int> umap;
int solution(vector<vector<string>> clothes) {
int answer = 1;
for (auto cloth : clothes) {
if (umap.find(cloth[1]) == umap.end())
umap.insert(make_pair(cloth[1], 1));
else
umap[cloth[1]]++;
}
for (auto kind : umap) {
answer *= (kind.second + 1);
}
return answer -= 1;
}
#include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
unordered_map<string,int> umap;
int solution(vector<vector<string>> clothes) {
int answer = 1;
for (auto cloth : clothes) {
if (umap.find(cloth[1]) == umap.end())
umap.insert(make_pair(cloth[1], 1));
else
umap[cloth[1]]++;
}
for (auto kind : umap) {
answer *= (kind.second + 1);
}
return answer -= 1;
}
int main(void)
{
vector<vector<string>> clothes = { {"yellow_hat", "headgear"},{"blue_sunglasses", "eyewear"},{"green_turban", "headgear"} };
cout << solution(clothes);
return 0;
}