chore:clean up

Signed-off-by: qinguoyi <1532979219@qq.com>
This commit is contained in:
qinguoyi 2024-08-07 22:17:28 +08:00
parent a98041281d
commit 2db9dc4811
1 changed files with 12 additions and 17 deletions

View File

@ -158,26 +158,21 @@ func findFeasiblePaths(groups []*GroupInfo, minConstraint, maxConstraint, target
})
}
if len(groups) < minConstraint {
return
}
if len(groups) == minConstraint {
var sum int
rootPath := new(dfsPath)
for _, i := range groups {
sum += i.value
rootPath.enqueue(i)
}
if sum >= target {
paths = append(paths, rootPath.next())
}
return
}
rootPath := new(dfsPath)
var dfsFunc func(int, int)
dfsFunc = func(sum, begin int) {
// directly check the sum
if len(groups) == minConstraint {
for _, group := range groups {
sum += group.value
rootPath.enqueue(group)
}
if sum >= target {
paths = append(paths, rootPath.next())
}
return
}
if sum >= target && rootPath.length() >= minConstraint && rootPath.length() <= maxConstraint {
paths = append(paths, rootPath.next())
return