We’re preparing your current view and syncing the latest data.
Given two integers n and k, return all possible combinations of k numbers out of the range [1, n]. You may return the answer in any order.
Two integers n and k.
A list of lists, where each list contains a unique combination of k numbers from 1 to n.
1 <= n <= 20 1 <= k <= n
Example 1
Input
n = 4, k = 2
Output
[[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
Explanation
All combinations of size 2 from numbers 1 to 4.