Skip to content

Practice Combination Sum III

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#216
LeetCode Problem

Combination Sum III

Problem Statement

Return all combinations of exactly k distinct numbers chosen from 1 through 9 whose sum is n. Use each number at most once. Do not include duplicate combinations; the result may be returned in any order.

Source: Combination Sum III on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
k = 3, n = 7
Output
[[1,2,4]]

# Example 2

Input
k = 3, n = 9
Output
[[1,2,6],[1,3,5],[2,3,4]]

# Example 3

Input
k = 4, n = 1
Output
[]

Constraints

2 <= k <= 9
1 <= n <= 60

Related LeetCode Problems

Practice more problems similar to Combination Sum III.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.