Skip to content

Commit 7c6b544

Browse files
authored
Create 0377-combination-sum-iv.kt
1 parent b26b1c2 commit 7c6b544

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

kotlin/0377-combination-sum-iv.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
class Solution {
2+
fun combinationSum4(nums: IntArray, target: Int): Int {
3+
val dp = IntArray(target + 1)
4+
5+
dp[0] = 1
6+
for (i in 1..target) {
7+
for (n in nums) {
8+
if(i - n >= 0) dp[i] += dp[i - n]
9+
}
10+
}
11+
12+
return dp[target]
13+
}
14+
}

0 commit comments

Comments
 (0)