HIT해

[JS 프로그래머스] 의상.해시 본문

Vue/JavaScript 알고리즘

[JS 프로그래머스] 의상.해시

힛해 2024. 1. 23. 20:45
728x90

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

 

프로그래머스

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

programmers.co.kr

function solution(clothes) {
    let box = new Map();
    let answer = 1;

    for(let i =0 ; i < clothes.length; i++){
        if(box.get(clothes[i][1])){
            box.set(clothes[i][1],box.get(clothes[i][1])+1)
        }else{
            box.set(clothes[i][1],1);
        }
    }

    for(let value of box.values()){

        answer *= (value + 1);
        console.log("값"+value)
        console.log(answer)
    }

    return answer - 1;
}