dsa2 min read
Shuffle an Array — Fisher-Yates O(n) Uniform Shuffle [Google Easy]
Implement Fisher-Yates shuffle for uniform random permutation. Every arrangement is equally probable. O(n) time O(1) extra space.
Read →
webcoderspeed.com
2 articles
Implement Fisher-Yates shuffle for uniform random permutation. Every arrangement is equally probable. O(n) time O(1) extra space.
Pick a random index of a target value with equal probability using reservoir sampling over the array.