-
Notifications
You must be signed in to change notification settings - Fork 383
Closed
Description
LeetCode Username
983. Minimum Cost For Tickets
Category of the bug
- Problem description
- Solved examples
- Problem constraints
- Problem hints
- Incorrect or missing "Related Topics"
- Incorrect test Case (Output of test case is incorrect as per the problem statement)
- Missing test Case (Incorrect/Inefficient Code getting accepted because of missing test cases)
- Editorial
- Programming language support
Description of the bug
If you buy 12 30-day tickets (all year pass), it only takes $36. But the answer given is 39.
Language used for code
Python3
Code used for Submit/Run operation
class Solution:
def mincostTickets(self, days: List[int], costs: List[int]) -> int:
m = len(days)
dp = [costs[2] * 12 for _ in range(m + 1)]
dp[0] = 0
tickets = [1, 7, 30]
for i in range(1, m + 1):
for j in range(3):
dp[i] = min(dp[i], dp[bisect.bisect_right(days, days[i-1] - tickets[j])] + costs[j])
return dp[m]
Screenshots

Metadata
Metadata
Assignees
Labels
No labels