프로그래머스(C++) - 의상

2025. 8. 11. 04:33·C++ 프로그래머스/Hash

●문제

 

●입출력

 

사용 알고리즘 : Hash / unoredered_map

 

문제해석 : 옷 종류와 옷 가짓수를 생각해서 푸는 문제

옷 가짓수 + 1 의 경우를 다 곱해서 -1 을 해주면 답이나온다

아무것도 안입는 선택지 -1 

똑같은 그 옷 종류를 안입는 경우  + 1을 해준다

 

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

using namespace std;

int solution(vector<vector<string>> clothes)
{
	int answer = 1;
	//옷이름, 옷종류
	//headgear -> yello_hat, green_turban
	//eyewear  -> blue_sunglasses
	unordered_map<string, int>clothesMap;
	for (auto c : clothes)
	{
		string type_Clothes = c[1];
		clothesMap[type_Clothes]++;
	}
	//(입는경우 + 안입는경우)
	for (auto it : clothesMap)
	{
		answer *= (it.second + 1);
	}
	//아에 아무것도 안입는경우는 제외
	return answer -1;
	
	
}

 

레벨 : 2

점수 : 1

'C++ 프로그래머스 > Hash' 카테고리의 다른 글

프로그래머스(C++) - 전화번호 목록  (0) 2025.08.08
프로그래머스(C++) - 완주하지 못한 선수  (0) 2025.08.08
Algorithm - Hash  (0) 2025.08.08
'C++ 프로그래머스/Hash' 카테고리의 다른 글
  • 프로그래머스(C++) - 전화번호 목록
  • 프로그래머스(C++) - 완주하지 못한 선수
  • Algorithm - Hash
lucodev
lucodev
언리얼 포폴개발 일기
  • lucodev
    루코 개발테이블
    lucodev
  • 전체
    오늘
    어제
    • 분류 전체보기 (213) N
      • Unreal 프로젝트 다이어리 (110) N
        • 첫번째 프로젝트 (73)
        • 두번째 프로젝트 (37) N
      • Unreal 팁 (8)
      • Unreal 디버깅 (8)
      • C++ 프로그래머스 (52)
        • Stack,Queue (7)
        • Hash (4)
        • Heap (2)
        • Sort (5)
        • Exhaustive search (5)
        • Greedy (2)
        • BFS , DFS (7)
        • Graph (2)
        • Dynamic Programming (1)
        • C++ Math (2)
        • 기타 문제 (14)
      • C++ 백준 (4)
      • C++ 팁 (1)
      • 개인 코테 & 스타디 <비공개> (29)
        • 코드 개인보관함 (9)
        • 코딩테스트+@ (11)
        • 알고리즘 스타디 (6)
        • 알고리즘 스타디 과제 (3)
        • 비공개 (0)
  • 인기 글

  • 최근 글

  • 최근 댓글

  • 링크

  • 공지사항

  • 블로그 메뉴

    • 홈
    • 태그
    • 방명록
  • 태그

    언리얼 모션매칭
    언리얼
    unreal 시퀀스
    unreal inventory
    unreal 파쿠르
    언리얼 컷씬
    unreal 인벤토리
    언리얼 motionmatching
    언리얼 비헤이비어트리
    unreal 모션매칭
    unreal
    언리얼 parkour
    언리얼 인벤토리
    언리얼 behavior tree
    언리얼 시퀀스
    언리얼 프로그래스바
    Unreal Parkour
    언리얼 behaviortree
    언리얼 파쿠르
    언리얼 ui
  • hELLO· Designed By정상우.v4.10.3
lucodev
프로그래머스(C++) - 의상
상단으로

티스토리툴바