반응형
https://school.programmers.co.kr/learn/courses/30/lessons/1845
프로그래머스
코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.
programmers.co.kr
function solution(nums) {
var answer = 0;
let map=new Map();
for(let num of nums){
if(map.has(num)){
map.set(num,map.get(num)+1)
}else {
map.set(num,1)
}
}
answer=Math.min(nums.length/2 , map.size)
return answer;
}
function solution(nums) {
const max = nums.length / 2;
const arr = [...new Set(nums)];
return arr.length > max ? max : arr.length
}
반응형
'CS (컴퓨터 사이언스) > Algorithm (알고리즘)' 카테고리의 다른 글
[프로그래머스] 스택/큐 1. 같은 숫자는 싫어 (0) | 2024.07.02 |
---|---|
[프로그래머스] 해쉬 2. 완주하지 못한 선수 (0) | 2024.06.27 |
[알고리즘] section7 결정알고리즘 11.뮤직비디오 (0) | 2024.05.17 |
[알고리즘] section7 정렬과 그리디, 결정알고리즘 - 이분탐색 (0) | 2024.05.14 |
[알고리즘] section 6 스택,큐 - 공주구하기 (0) | 2024.05.13 |