https://school.programmers.co.kr/learn/courses/30/lessons/1845
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
#include <vector>
#include <unordered_map>
#include <iostream>
using namespace std;
int solution(vector<int> nums)
{
int answer = 0;
unordered_map<int, int> pokemon;
for (int index : nums){
pokemon[index]++;
}
if (pokemon.size() < nums.size()/2) answer = pokemon.size();
else answer = nums.size()/2;
return answer;
}
728x90
반응형
'공부 > C++' 카테고리의 다른 글
[C++] 프로그래머스 의상 (0) | 2025.04.04 |
---|---|
[C++] 프로그래머스 전화번호 목록 (0) | 2025.04.04 |
[C++] 프로그래머스 완주하지 못한 선수 (0) | 2025.04.04 |
[C++] 프로그래머스 대소문자 바꿔서 출력하기 (0) | 2025.04.04 |
[C++] 코딩테스트 참고 (0) | 2025.04.04 |