Skip to content

Latest commit

 

History

History
25 lines (19 loc) · 543 Bytes

File metadata and controls

25 lines (19 loc) · 543 Bytes

프로그래머스 Level1 : 찾아라 프로그래밍 마에스터 폰켓몬

import java.util.HashSet;
class Solution {
    public int solution(int[] nums) {
        int answer = 0;
        int cnt = nums.length/2;
        HashSet<Integer> set = new HashSet<>();
        
        for(int num : nums){
          if(set.add(num)){
              answer++;
          }
        }
        
        answer = answer>cnt? cnt : answer;

        return answer;
    }
}