Find all subsets of length k in an array
Recursion is your friend for this task. For each element – “guess” if it is in the current subset, and recursively invoke with the guess and a smaller superset you can select from. Doing so for both the “yes” and “no” guesses – will result in all possible subsets. Restraining yourself to a certain length … Read more