73. Combinations

MediumBacktracking

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.

Examples

Input: 4 2

Output: [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]

Explanation: All 6 ways to choose 2 numbers from 1..4.

Constraints

  • 1 <= n <= 20
  • 1 <= k <= n
Loading...

Run checks all cases above. Submit evaluates all test cases.