Problem
Given two natural numbers n and m, write a solution function that returns all sets of m numbers selected from the integers between 1 and n that satisfy the following conditions:
Conditions:
- Each set contains exactly numbers.
- .
- If multiple sets satisfy the above conditions, return the sets in lexicographical order.
Constraints
nis a natural number less than or equal to 15.mis a natural number less than or equal ton.
Test Case
| Test Case Number | n | m | return |
|---|---|---|---|
| 1 | 3 | 2 | [[1,2],[1,3],[2,3]] |
| 2 | 5 | 1 | [[1],[2],[3],[4],[5]] |
| 3 | 5 | 5 | [[1,2,3,4,5]] |
Explanation for Test Case 1
- From the integers
1,2, and3, selecting and arranging 2 numbers in ascending order produces the following 3 sets: [1,2], [1,3], [2,3]. - Sorting these sets lexicographically results in [[1,2],[1,3],[2,3]].
Explanation for Test Case 2
- From the integers
1,2,3,4, and5, selecting and arranging 1 number in ascending order produces the following 5 sets: [1], [2], [3], [4], [5]. - Sorting these sets lexicographically results in [[1],[2],[3],[4],[5]].
Explanation for Test Case 3
- From the integers
1,2,3,4, and5, selecting and arranging all 5 numbers in ascending order produces a single set: [1,2,3,4,5]. - Sorting these sets lexicographically results in [[1,2,3,4,5]].