I am confused by a condition of this question. someone explain it please.


  • 1
    R

    Question says

    Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.

    Each number in C may only be used once in the combination.

    For example, given candidate set [10, 1, 2, 7, 6, 1, 5] and target 8,
    A solution set is:

    [
    [1, 7],
    [1, 2, 5],
    [2, 6],
    [1, 1, 6]
    ]

    i am confused of this condition
    Each number in C may only be used once in the combination.
    as in this example it has the combination [1,1,6] i.e. repeating 1's

    it is highly appreciable if somebody explains it. Thank you .


  • 0
    L

    i found the same problem ,but after reading carefully and analyzing the conditions you will found that it is not a problem. Try again yourself before asking here.


  • 0
    C

    The example [1, 1, 6], there is no duplicate number in the combination, because there are two 1 in C.

    The purpose is that you are not supposed to give a [1, 1, 1, 1, 1, 1, 1, 1] as solution.


  • 0
    W

    C is a collection, not a set, so C can have a bunch of duplicates in it. You can use any number at a specific index twice. So you can use both C[0] = 5 and C[3] = 5, but not C[1] = 1 more than once.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.