Next Insurance interview question

In the second interview: given an array, and a function rand(n) which return an integer between 0 to n, return a permutation of the array.