77. Combinations

Practice Combinations for free on NudgeCode: Medium, Backtracking pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return every way to choose k different numbers from 1 to n. The combinations, and the values inside each, can be in any order.

Example

n = 4, k = 2  ->  [[1,2],[1,3],[1,4],[2,3],[2,4],[3,4]]

Constraints