Skip to content

Commit f10773d

Browse files
authored
Update Solution.swift
1 parent 8b115c7 commit f10773d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
class Solution {
22
func combinationSum4(_ nums: [Int], _ target: Int) -> Int {
33
var dp = [Int](repeating: 0, count: target + 1)
4-
dp[0] = 1
4+
dp[0] = 1
55

66
for i in 1...target {
77
for num in nums {
8-
if i >= num {
8+
if i >= num, dp[i] <= Int.max - dp[i - num] {
99
dp[i] += dp[i - num]
1010
}
1111
}
1212
}
13-
13+
1414
return dp[target]
1515
}
16-
}
16+
}

0 commit comments

Comments
 (0)