Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions knapsack/knapsack.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ def knapsack(capacity: int, weights: list[int], values: list[int], counter: int)
which is the limit of the capacity.
"""

# Invalid Case
if len(values)!=len(weights):
return -1

# Base Case
if counter == 0 or capacity == 0:
return 0
Expand Down