728x90
반응형
의상 문제
내 코드
using System;
using System.Collections.Generic;
public class Solution {
public int solution(string[,] clothes) {
int answer = 1;
Dictionary<string, int> dic = new Dictionary<string, int>();
dic.Add(clothes[0, 1], 0);
for (int i = 0; i < clothes.GetLength(0); i++)
{
if(dic.ContainsKey(clothes[i, 1]))
{
dic[clothes[i, 1]]++;
}
else
{
dic.Add(clothes[i, 1],1);
}
}
foreach(string key in dic.Keys)
{
// *(한옷의 종류 수 +1(안입는 경우의 수))
answer *= dic[key] + 1;
}
answer -= 1; // - 아무것도 안입는 경우의 수
return answer;
}
}
728x90
반응형
'코딩테스트_c# > 프로그래머스' 카테고리의 다른 글
프로그래머스 ) 롤케이크 자르기 Level.2_C# (0) | 2024.11.27 |
---|---|
프로그래머스 ) 두 큐 합 같게 만들기 Level.2_ C# (0) | 2024.11.12 |
프로그래머스 ) 코딩테스트 연습 - 성격 유형 검사하기 Level.1_C# (0) | 2024.11.11 |
프로그래머스 ) 코딩테스트 연습 - 호텔 대실 Level.2_C# (0) | 2024.07.26 |
프로그래머스 ) 코딩테스트 연습 - 신고결과 받기 Level.1_C# (0) | 2024.07.19 |