Set 선언에서 Cannot find symbol 오류가 자꾸 뜹니다 ㅠㅠ
스펠링이나 문법을 잘못 알고 있나 꼼꼼히 확인했지만 이유를 모르겠어서 질문드려요
컴파일 오류의 원인이 뭘까요..
import java.util.Arrays;
import java.util.Set;
public class Solution {
public int solution(int[] nums) {
int getMaxValue = nums.length / 2;
int answer = 0;
// int[] distinct = Arrays.stream(nums)
// .distinct()
// .toArray();
// int deduplication = distinct.length;
Set<Integer> distinct = new HashSet<>();
for (int num : nums) {
distinct.add(num);
}
int deduplication = distinct.size();
if (getMaxValue > deduplication) {
answer = getMaxValue;
}
else { answer = deduplication; }
return answer;
}
}
hashSet 별도로 추가해주니까 통과되었습니다