위장

108번뇌·2020년 10월 24일
0

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

import java.util.*;

class Solution {
    public int solution(String[][] clothes) {
        int answer = 1;

        HashMap<String, Integer> hashmap = new HashMap<>();

        for(int i=0; i<clothes.length; i++)
        {
            if(hashmap.containsKey(clothes[i][1]))
            {
                hashmap.put(clothes[i][1], hashmap.get(clothes[i][1])+1);
                continue;
            }
            hashmap.put(clothes[i][1], 1);
        }

        for(var value : hashmap.keySet())
        {
            answer*=hashmap.get(value)+1;
        }

        return answer-1;
    }
}

익힐것 :
1. HashMap
2. map.put
3. for(var value : hashmap.ketSet())

profile
내일 아침 눈을 떳을 때, '기대되는 오늘 하루를 만들기 위해' 나는 오늘도 생각하고 고민한다.

0개의 댓글