Skip to content

Commit d7e18e8

Browse files
Update exercises/practice/knapsack/.meta/example.nim
knapsack: omit the template parameter Co-authored-by: ynfle <23086821+ynfle@users.noreply.github.com>
1 parent d4ad759 commit d7e18e8

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

exercises/practice/knapsack/.meta/example.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type Item = tuple[weight: int, value: int]
22

33
proc maximumValue*(maximumWeight: int, items: openArray[Item]): int =
4-
var dp = newSeq[int](maximumWeight + 1)
4+
var dp = newSeq(maximumWeight + 1)
55
for item in items:
66
for weight in countdown(maximumWeight, item.weight):
77
dp[weight] = max(dp[weight], item.value + dp[weight - item.weight])

0 commit comments

Comments
 (0)