백준 알고리즘 3052번 풀다가 자바에 중복된 값을 허용하지 않는 클래스는 없을까? 라는 생각이 들어 구글링.
HashSet 특징
import java.util.HashSet;
import java.util.Scanner;
//백준 3052번
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
HashSet<Integer> hash = new HashSet<Integer>();
for(int i = 0; i<10; i++){
hash.add(sc.nextInt() % 42);
}
sc.close();
System.out.println(hash.size());
}
}