The problem with this problem


  • 0
    F

    It's explicitly required in the original problem, that no duplicated combinations are allowed. However, the expected answer itself allows duplicated combinations! Try out this test case:
    [2,2,4,6]
    12

    The expected answer will be:
    [[2,2,2,2,2,2],[2,2,2,2,2,2],[2,2,2,2,2,2],[2,2,2,2,4],[2,2,2,2,2,2],[2,2,2,2,4],[2,2,2,6],[2,2,2,2,2,2],[2,2,2,2,4],[2,2,2,6],[2,2,4,4],[2,2,2,2,2,2],[2,2,2,2,4],[2,2,2,6],[2,2,4,4],[2,4,6],[2,2,2,2,2,2],[2,2,2,2,4],[2,2,2,6],[2,2,4,4],[2,4,6],[4,4,4],[6,6]]

    You can see many duplicated combinations in the final expected answer.


  • 2
    H

    The input is supposed to be a set, and by definition there shouldn't be any duplicates in a set. Your input contains two "2"s so it's not a valid input. You can argue though that the program then should expect an input set instead of an array or do a conversion first but I don't think they bothered with it.


Log in to reply
 

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