One way to represent a set is by using a
bit array:
- Create an array of size (max - min + 1).
- Initialize each element of this bit array to 0.
- When you generate a random number, x, check the value of the element in the bit array at index [x - min].
- If the bit array value is 0, set the value at [x-min] in the bit array to 1.
- If the bit array value is 1, then x already exists in the set, so generate another random number.
- Repeat the process until you've added setSize number of elements to the set.