Arrays.asList(perm).contains(num)
from How to check if an array contains a specific value?
for (int i = 0; i < perm.length; i++)
this is not enough for loops like this, if a collision occurs, some slots would not be initialized.
In general , for this task it is better to initialize the array with the values ββin order, and then shuffle it using random permutation indices
Nikolay Kuznetsov Dec 09 '12 at 16:12 2012-12-09 16:12
source share