My Space

반응형

코드
public int solution(int[] nums) {
        HashSet<Integer> hs = new HashSet<Integer>();
		
		for(int i : nums) {
			if(!hs.contains(i)) {
				hs.add(i);
			}
		}
		return nums.length/2>hs.size()?hs.size():nums.length/2;
    }

공유하기

facebook twitter kakaoTalk kakaostory naver band
loading