Combinations
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.

30:00

Combinations
medium
Topics
Companies

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]]
Constraints:
  • 1n201 \leq n \leq 20

  • 1kn1 \leq k \leq n

Input
arr ={"n":4,"k":2}

Find all combinations of 2 numbers from [1, 4]

n = 4
k = 2
Found: 0 combinations
Available Numbers [1, 4]
1
2
3
4
Current Combination (0/2)

Empty

Results Found (0)

No combinations found yet

Variables
No variables to display
DepthFunction Call
Stack empty
0/26