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 }