Medium · Backtracking
Combinations
Given integers n and k, return all combinations of k distinct numbers chosen from 1 to n, each combination once, in any order.
Examples
Example 1
n=4, k=2Output: 6 combos
Example 2
n=5, k=3Output: 10 combos
Rebuild it in the studio
Core interview problems are free with a full runner and lessons; Pro opens the complete library.