Skip to content
This repository was archived by the owner on Apr 20, 2024. It is now read-only.

Commit 0472d92

Browse files
committed
created problem58
1 parent d0709f2 commit 0472d92

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

problem58/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# 216. Combination Sum III
2+
3+
Find all valid combinations of k numbers that sum up to n such that the following conditions are true:
4+
5+
Only numbers 1 through 9 are used.
6+
Each number is used at most once.
7+
Return a list of all possible valid combinations. The list must not contain the same combination twice, and the combinations may be returned in any order.
8+
9+
10+
## Example 1:
11+
12+
Input: k = 3, n = 7
13+
Output: [[1,2,4]]
14+
Explanation:
15+
1 + 2 + 4 = 7
16+
There are no other valid combinations.
17+
18+
## Example 2:
19+
20+
Input: k = 3, n = 9
21+
Output: [[1,2,6],[1,3,5],[2,3,4]]
22+
Explanation:
23+
1 + 2 + 6 = 9
24+
1 + 3 + 5 = 9
25+
2 + 3 + 4 = 9
26+
There are no other valid combinations.
27+
28+
## Example 3:
29+
30+
Input: k = 4, n = 1
31+
Output: []
32+
Explanation: There are no valid combinations.
33+
Using 4 different numbers in the range [1,9], the smallest sum we can get is 1+2+3+4 = 10 and since 10 > 1, there are no valid combination.
34+
35+
36+
## Constraints:
37+
38+
2 <= k <= 9
39+
1 <= n <= 60

0 commit comments

Comments
 (0)