본 블로그는 비상업적, 비영리적 용도의 학업만을 위해 글을 게시합니다.
#include <string>
#include <vector>
#include <map>
using namespace std;
int solution(vector<vector<string>> clothes) {
int answer = 0;
int recurrence = 0;
map<string, int> hash;
for(int i = 0; i < clothes.size(); i++)
{
if(hash.count(clothes[i][1]))
hash[clothes[i][1]]++;
else
hash[clothes[i][1]] = 1;
}
if(hash.size() == 1)
return clothes.size();
for(auto &i : hash)
answer = (i.second * (answer + 1)) + answer;
return answer;
}
#include <string>
#include <vector>
#include <unordered_map>
using namespace std;
int solution(vector<vector<string>> clothes) {
int answer = 1;
unordered_map <string, int> attributes;
for(int i = 0; i < clothes.size(); i++)
attributes[clothes[i][1]]++;
for(auto it = attributes.begin(); it != attributes.end(); it++)
answer *= (it->second+1);
answer--;
return answer;
}