[프로그래머스] 폰켓몬 풀이



1. 문제

https://programmers.co.kr/learn/courses/30/lessons/1845

2. 풀이

2.1. python

def solution(nums):
    N = len(nums)/2
    nums = set(nums)
    return len(nums) if N >= len(nums) else N

2.2. C++

#include <iostream>
#include <algorithm>
#include <set>
using namespace std;

int solution(vector<int> nums)
{
    set<int> s;
    for (int i=0; i<nums.size() ; i++)
        s.insert(nums[i]);
    
    return min(s.size(), nums.size()/2);
}