문제
https://school.programmers.co.kr/learn/courses/30/lessons/1845
코드
#include <vector>
#include <map>
using namespace std;
int solution(vector<int> nums)
{
int answer = 0;
map<int,int>m;
for(int i=0;i<nums.size();i++){
m.insert({nums[i],1});
}
answer= m.size()>nums.size()/2? nums.size()/2 : m.size();
return answer;
}'PS > Programmers' 카테고리의 다른 글
| [프로그래머스 Lv.2] 카펫(C++) (0) | 2025.04.03 |
|---|---|
| [프로그래머스 Lv.1] 같은 숫자는 싫어(C++) (0) | 2025.03.31 |
| [프로그래머스 Lv.1] 완주하지 못한 선수(C++) (0) | 2025.03.24 |
| [프로그래머스 Lv.2] 서버 증설 횟수(C++) (0) | 2025.03.22 |
| [프로그래머스 Lv.1] 택배 상자 꺼내기(C++) (0) | 2025.03.20 |
댓글