Question bank › Backtracking
Dsa Backtracking Easy

All Unique Combinations

Given an array of integers `nums`, find all unique combinations of elements that sum up to a target value. Each combination should be stored in the result set as a sorted tuple. You may use each number in `nums` only once in each combination, and you cannot use the same combination of numbers in different orders. Output the sorted list of unique combinations. Input: - The first line contains an integer `n` (1 ≤ n ≤ 20), the number of integers. - The second line contains `n` space-separated integers (1 ≤ nums[i] ≤ 50), the elements of the array. - The third line contains a target integer `target` (1 ≤ target ≤ 100). Output: - Print the unique combinations as a list of tuples sorted in ascending order. Example: Input: 5 10 1 2 7 6 8 Output: [(1, 2, 5), (1, 7), (2, 6)]

Key concepts

backtrackingcombinationsarrays

Practise this out loud — free

Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.

🎙 Practise this question now
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.