Dynamic Programming: Knapsack - Minimum Cost for Tickets
Given the following code snippet for minimum cost tickets, which line causes incorrect results due to improper index handling when calculating dp values?
for i in range(len(days)-1, -1, -1):
j = i
while j < len(days) and days[j] < days[i] + durations[k]:
j += 1
dp[i] = min(dp[i], costs[k] + dp[j])