Combinations

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.

Solution:

Simply using recursion. Use a vector called prefix to generate the combination of numbers.

The following code passes the LeetCode Online Large Judge.

Comments