Question: Given an integer n, write a function to return all possible combinations of k numbers out of the range [1, n]. You may return the

Given an integer n, write a function to return all possible combinations of k numbers out of the range [1, n]. You may return the combinations in any order.

For example, if n = 4 and k = 2, the function should return [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]].

Step by Step Solution

3.43 Rating (156 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

The detailed answer for the above question is provided below def combinen k def backtrackstart curr ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!