import java.util.Random;
/**
* Created by yang on 1/3/17.
*/
public class Solution {
public static int randomSlot(int n, int[] empty) {
if (empty.length > n) return 0;
Random rand = new Random();
int[] left = new int[n - empty.length];
int i = 0, j = 0, index = 0;
while (index < left.length) {
if (j < empty.length) {
if (empty[j] == i + 1) {
j++;
i++;
continue;
}
}
left[index] = ++i;
index++;
}
/*for (int num : left) {
System.out.print(num + " ");
}*/
return left[rand.nextInt(left.length)];
}
public static void main(String[] args) {
int[] empty = new int[]{3, 5};
for (int i = 0; i < 15; i++) {
int rst = randomSlot(8, empty);
System.out.println(rst);
}
}
}