본문 바로가기
Coding Test/Programmers

[Programmers] (해시) Lv 2. 의상

by song.ift 2023. 6. 15.

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

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

 

#include <string>
#include <vector>
#include <unordered_map>
#include <algorithm>

using namespace std;

int solution(vector<vector<string>> clothes) {
    int answer = 1;
    unordered_map<string, int> m;

    for_each(clothes.begin(), clothes.end(), [&](const auto& v) { ++m[v[1]]; });

    for (auto& e : m) answer *= (e.second + 1); // 각각 하나만 입는 경우가 있기 때문에 +1
    return --answer;
}

GitHub : https://github.com/developeSHG/Algorithm-Baekjoon_Programmers/blob/5c596d1b1648e2738b4cdcdbf8bcfd56871f11d0/%ED%94%84%EB%A1%9C%EA%B7%B8%EB%9E%98%EB%A8%B8%EC%8A%A4/lv2/42578.%E2%80%85%EC%9D%98%EC%83%81/%EC%9D%98%EC%83%81.cpp

 

GitHub - developeSHG/Algorithm-Baekjoon_Programmers: 백준 and 프로그래머스 소스코드

백준 and 프로그래머스 소스코드. Contribute to developeSHG/Algorithm-Baekjoon_Programmers development by creating an account on GitHub.

github.com

 

댓글