I guess there is a test case missing on Combination Sum


  • 0
    H

    I guess there is a test case missing on Combination Sum which is target is less than any elementary in the array. Try target = 1, int[] candidates = new int[]{2, 3}. My code doesn't consider this case, but still pass all tests. I tried on my local testing code, it failed. Please correct me.

    By the way, when I added "candidates[i] > target " this condition, it runs much faster than before. The modified code is about 280ms (JAVA).


  • 0

    Could you please elaborate on what you mean by "I tried on my local testing code, it failed"?

    I tried running your accepted code for the test case you provided, it does return the correct output, which is an empty list [].


  • 0
    H

    You are right. There is something wrong with my local test. Thanks a lot. I will close this question.


Log in to reply
 

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