Combination
Given two integers n _and _k, return all possible combinations of k _numbers out of 1 ... _n.
Example
Input:
n = 4, k = 2
Output:
[
[2,4],
[3,4],
[2,3],
[1,2],
[1,3],
[1,4],
]Note
递归出口:k减到0
start从1开始
Time: O(n^min(k, n - k))
Space: O(n)
Code
Last updated