You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Since in each recursive call the index only moves forward (i starts from index), even if there are duplicate numbers in the array, they will not result in duplicate combinations.
For example, for the array [2, 3, 6, 7] and the target value 7, the combination [2, 2, 3] will only be considered once when the loop reaches 2. Subsequent iterations will not consider [2, 3, 2] or [3, 2, 2], thus avoiding duplicate combinations.
You can try submitting my code and you will get the result of accept. This is a screenshot of the result I just submitted.
You code does not skip the duplicated combination.
You need to add skip duplicated combination . See below.
The text was updated successfully, but these errors were encountered: