Randomize dynamic array with unique values

In reply to megamind:

Yeah I got your logic.
You are randomizing the value and adding to the queue by randomizing for 10 times.
But can we modify the logic such that a dynamic array can be used instead of queue?