- Notifications
You must be signed in to change notification settings - Fork85
Commitacf5d3f
committed
Create Combinations.java
Problem statement: Given two integers n and k, return all possible combinations of k numbers out of 1 ... n. For example, If n = 4 and k = 2, a solution is: [[2,4], [3,4], [2,3], [1,2], [1,3], [1,4]]Strategy: Determin the starting number `start` among all k numbers as a first step. Afterwards, repeat the same problem by changing k to k-1 and changing possible starting number from `start` to `start+1`1 parent8cfe703 commitacf5d3f
1 file changed
+26
-0
lines changedLines changed: 26 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + |
0 commit comments
Comments
(0)