Shuffle an array with a random-integer function

0
Remix

Using only a function that returns a uniform random integer in a range, shuffle an array (for example a deck of cards) so every permutation is equally likely. Implement Fisher-Yates, explain why it is uniform, and why a naive swap-with-any-position version is not.

GoogleTechnical phone screenLast asked Dec 2025
No answer yet. Write the first one; the best answer gets endorsed.