Skip to content

Commit 6512dbf

Browse files
authored
Update Solution.swift
1 parent e61ec21 commit 6512dbf

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,15 +1,15 @@
11
class Solution {
22
func coinChange(_ coins: [Int], _ amount: Int) -> Int {
3-
43
var dp = [Int](repeating: amount + 1, count: amount + 1)
54
dp[0] = 0
6-
5+
76
for coin in coins {
7+
if coin > amount { continue }
88
for j in coin...amount {
99
dp[j] = min(dp[j], dp[j - coin] + 1)
1010
}
1111
}
12-
12+
1313
return dp[amount] > amount ? -1 : dp[amount]
1414
}
15-
}
15+
}

0 commit comments

Comments
 (0)