

import java.util.*;
class Solution {
    public int solution(int[] nums) {
        int ans = 0;
        int cnt =0;
        
        Arrays.sort(nums);
        
        for(int i : nums){
            if(i != ans ) {
                ans = i;
                cnt++;
            }
            if(cnt == nums.length/2) break;
        }
        
        return cnt;
    }
}
nums의 포켓몬 종류를 저장할 i와 종류의 개수를 저장할 cnt를 변수로 할당하고
정렬된 nums를 차례대로 돌며 포켓몬의 종류가 이전에 안나왔던것이라면 cnt++
만약 cnt가 N/2와 같아진다면 멈추고 cnt를 출력