import java.util.HashSet;
public class NUM1845 {
public static void main(String[] args) {
int[] nums = {3,3,3,2,2,4};
System.out.println(solution(nums));
}
public static int solution(int[] nums) {
int max = nums.length / 2;
HashSet<Integer> poketmons = new HashSet<>();
for (int num : nums) {
poketmons.add(num);
}
if(poketmons.size() >= max) answer = max;
else answer = poketmons.size();
return answer;
}
}
*다른 분들의 코드를 참고하여 작성했습니다