Skip to content

983. Minimum Cost For Tickets #19241

@atpro0424

Description

@atpro0424

LeetCode Username

antpro0424

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

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions