Problem Statement:

Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.
You may return the answer in any order.

Example :
Input: n = 4, k = 2


  • NOTE: I highly recommend going through the Backtracking chapters in the order they are given in the Index page to get the most out of it and be able to build a rock-solid understanding.


Login to Access Content

Java Code:

Login to Access Content

Python Code:

Login to Access Content

Don't forget to take in-depth look at the other backtracking problems because that is what would make you comfortable with using the backtracking template and master the art of Backtracking:


If you have any feedback, please use this form:

Help Your Friends save 25% on our products