(int[] array)
| 5 | public class Question { |
| 6 | |
| 7 | public static void checkDuplicates(int[] array) { |
| 8 | BitSet bs = new BitSet(32000); |
| 9 | for (int i = 0; i < array.length; i++) { |
| 10 | int num = array[i]; |
| 11 | int num0 = num - 1; // bitset starts at 0, numbers start at 1 |
| 12 | if (bs.get(num0)) { |
| 13 | System.out.println(num); |
| 14 | } else { |
| 15 | bs.set(num0); |
| 16 | } |
| 17 | } |
| 18 | } |
| 19 | |
| 20 | public static void main(String[] args) { |
| 21 | int[] array = AssortedMethods.randomArray(30, 1, 30); |