Dashboard
LC #77
Combinations
Pattern · ?AmazonGoogleMeta
Problem
Return all combinations of k numbers chosen from range [1, n].
Constraints
- 1 ≤ n ≤ 20
- 1 ≤ k ≤ n
Example
- Input
- n = 4, k = 2
- Output
- [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]
- Why
- C(4,2) = 6 combinations. Choose 2 from [1,2,3,4]
Spot the pattern
Which pattern cracks it?
Hints
One at a time