Today, I had a chance to use Fisher Yates algorithm. Fisher Yates algorithm shuffles the items in a list.
Here is the problem statement:
Out of an array of N items, randomly pick K items where 0 < K < N.
My first naive solution of the problem was as follows:
IEnumerable<int> RandomSelect(int n, int k) { var random = new Random(); var set = new HashSet<int>(); while(set.Count…