Combinations of n choose k
Your task
Given two integers n (1..13) and k (0..n), return all combinations of k numbers chosen from the range 1..n. Each combination is an ascending list and combinations themselves do not repeat. Return the full list sorted ascending; note k = 0 yields a single empty combination.
Examples
combine(n: int, k: int) -> list[list[int]]Example 1
Input
combine(4, 2)Output
[[1, 2], [1, 3], [1, 4], [2, 3], [2, 4], [3, 4]]