halfrost / LeetCode-Go

✅ Solutions to LeetCode by Go, 100% test coverage, runtime beats 100% / LeetCode 题解
https://books.halfrost.com/leetcode
MIT License
32.76k stars 5.68k forks source link

There is a bug in your Leetcode-go 39 combination sum #288

Open shiiaii opened 3 weeks ago

shiiaii commented 3 weeks ago

You code does not skip the duplicated combination. You need to add skip duplicated combination . See below.

        if nums[i] > target  {
            break
        }
        // the following to skip the duplicated combination
        if (len(c)!=0 && nums[i] < c[len(c)-1]) {
            continue
        }
haowan1015 commented 3 weeks ago

呵呵,来信收到,谢谢

xiaokuer commented 3 weeks ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

halfrost commented 3 weeks ago

@shiiaii Hi, about deduplication mechanism:

You can try submitting my code and you will get the result of accept. This is a screenshot of the result I just submitted.

image