I find a loophole, my algorithm contains duplicate combinations, But it can still be Accepted


  • 2
    L

    I test this case.

    candidates = {1,1}  target = 1
    

    my algorithm return {{1}, {1}}, But it can still be Accepted.


  • 0
    S

    Thanks. Good catch! Could you please share your code with comment in it and algorithm explanation?


  • 0
    C
    This post is deleted!

  • 0
    C

    My solution has same issue. It will return {{1}, {1}} but still be accepted. Does the test cases contain the case that have duplicate elements?


  • 9
    J

    I think this question is misleading. As it says that we can choose the same number from the candidate numbers repeatedly, it would be meaningless if the candidates has duplicate numbers. So I guess the test cases assume that candidate numbers are mutually different.


  • 0
    F

    Elements in a Set should be mutually different. That's the definition of a Set.


  • 0
    J

    That's the answer! Thanks!


Log in to reply
 

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