Grad shape
Grad shape

Combination Sum 2

Get started
hero image
    🙏

    জয়  শ্রী  রাম

    🕉





Problem Statement:


Given an array of integer numbers and a target number, find all unique combinations in the array where the numbers sum to target.
Each number in the given array may only be used once in the combination.
Your result cannot contain any duplicate combinations.

Examples:
Input = [10,1,2,7,6,1], target = 8
Output:
[
[1,1,6],
[1,7],
[2,6]
]


Example 2:
Input: candidates = [2,5,2,1,2], target = 5
Output:
[
[1,2,2],
[5]
]


Solution:


  • NOTE: I highly recommend going through the Backtracking chapters in the order they are given in the Index page to get the most out of it and be able to build a rock-solid understanding.


Algorithm:



Login to Access Content


Java Code:



Login to Access Content



Python Code:



Login to Access Content




Don't forget to take in-depth look at the other backtracking problems because that is what would make you comfortable with using the backtracking template and master the art of Backtracking:


Instructor: