프로그래머스 폰켓몬
-
Level1) 폰켓몬PS/programmers 2021. 5. 1. 10:57
1234567891011121314151617import java.util.*; public class Level1_폰켓몬 { public static int solution(int[] nums) { Set set = new HashSet(); for (int num : nums) { set.add(num); } return Math.min(set.size(), nums.length/2); } public static void main(String[] args) { int[] nums = {3,3,3,2,2,4}; System.out.println(solution(nums)); }}Colored by Color Scriptercs