Skip to content

Commit 8b115c7

Browse files
authored
Update README.md
1 parent 1a3da38 commit 8b115c7

File tree

1 file changed

+3
-3
lines changed
  • lcof2/剑指 Offer II 104. 排列的数目

1 file changed

+3
-3
lines changed

lcof2/剑指 Offer II 104. 排列的数目/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,16 @@ func combinationSum4(nums []int, target int) int {
147147
class Solution {
148148
func combinationSum4(_ nums: [Int], _ target: Int) -> Int {
149149
var dp = [Int](repeating: 0, count: target + 1)
150-
dp[0] = 1
150+
dp[0] = 1
151151

152152
for i in 1...target {
153153
for num in nums {
154-
if i >= num {
154+
if i >= num, dp[i] <= Int.max - dp[i - num] {
155155
dp[i] += dp[i - num]
156156
}
157157
}
158158
}
159-
159+
160160
return dp[target]
161161
}
162162
}

0 commit comments

Comments
 (0)