Level1) 폰켓몬
2021. 5. 1. 10:57ㆍPS/programmers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | import java.util.*; public class Level1_폰켓몬 { public static int solution(int[] nums) { Set<Integer> 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)); } } | cs |
'PS > programmers' 카테고리의 다른 글
Level2) 위장 (0) | 2021.05.03 |
---|---|
Level1) 내적 (0) | 2021.05.02 |
Level1) 소수구하기 (0) | 2021.04.30 |
Level1) 신규아이디추천 (0) | 2021.04.29 |
Level1) 3진법 뒤집기 (0) | 2021.04.28 |