Skip to content

Commit e8d06e3

Browse files
committed
Modify dp solution
1 parent 805443d commit e8d06e3

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

dp.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
def solve_pizza(nums, target):
22
dp = [[None for _ in range(len(nums))] for _ in range(target+1)]
33

4-
dp[nums[0]][0] = [nums[0]]
4+
dp[nums[0]][0] = [0]
55

66
for j in range(len(nums)):
77
dp[0][j] = []
@@ -14,7 +14,7 @@ def solve_pizza(nums, target):
1414
continue
1515
if i-nums[j] >= 0:
1616
if dp[i-nums[j]][j-1] is not None:
17-
dp[i][j] = list(dp[i-nums[j]][j-1] + [nums[j]])
17+
dp[i][j] = list(dp[i-nums[j]][j-1] + [j])
1818

1919
for i in range(target, -1, -1):
2020
if dp[i][-1] is not None:

0 commit comments

Comments
 (0)