Given two integers n and k, return all possible combinations of k numbers chosen from the range [1, n]. You may return the answer in any order.
Example 1
Input: n = 4, k = 2
Output: [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
Explanation: Choosing 2 numbers from 1-4 gives C(4,2) = 6 pairs: [1,2], [1,3], [1,4], [2,3], [2,4] and [3,4].
Example 2
Input: n = 1, k = 1
Output: [[1]]
Explanation: There is only one number to choose, so the answer is [[1]].
Example 3
Input: n = 3, k = 3
Output: [[1,2,3]]
Explanation: Choosing all 3 numbers from 1-3 can be done in only one way: [1,2,3].
Build a combination in increasing order. At each step choose the next number to be larger than the last picked (via a start index), which avoids duplicates and reordering. When the path reaches length k, it's a valid combination.
Run checks all cases above. Submit evaluates all test cases.