Given an array t[100] which contains numbers between 1..99. Return the
duplicated value
import java.util.HashSet;
import java.util.Set;
public class Duplicate {
public static void main(String args[]) {
Integer[] t = new Integer[100];
for (int i = 0; i < 100; i++) {
t[i] = (int) (Math.random() * 100);
}
Set<Integer> set = new HashSet<Integer>();
for (int i = 0; i < 100; i++) {
for (int j = 0; j < 100; j++) {
if (t[i] == t[j]) {
set.add(t[i]);
}
}
}
for (Integer i : set) {
System.out.print(" " + i);
}
}
}