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.

Constraints

  • 1 <= n <= 20
  • 1 <= k <= n
Saving… · 3 lines
class Solution:
def generateCombinations(self, n: int, k: int) -> List[List[int]]:

Console

Click Run to execute sample tests.