Skip to main content
PreparationZone Logo
PreparationZone
Back to Coding

Coding · Medium · Pro

Combinations of k numbers from 1..n

CodingRecursionBacktrackingSenior
Model answerPreview

Approach

  • Start next pick from start to avoid duplicates.
  • Stop when path size == k.

Java Solution

Java
public List<List<Integer>> combine(int n, int k) {
    List<List<Integer>> res = new Arra…