Skip to content

Practice Minimum Cost For Tickets

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#983
LeetCode Problem

Minimum Cost For Tickets

Problem Statement

Cover every travel day listed in days, where calendar days range from 1 through 365. Buy passes lasting 1, 7 or 30 consecutive days for costs[0], costs[1] or costs[2] respectively. A pass beginning on day d includes d and its following duration - 1 days. Return the lowest total cost that covers all listed travel days.

Source: Minimum Cost For Tickets on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
days = [1,4,6,7,8,20], costs = [2,7,15]
Output
11

# Example 2

Input
days = [1,2,3,4,5,6,7,8,9,10,30,31], costs = [2,7,15]
Output
17

Constraints

1 <= days.length <= 365
1 <= days[i] <= 365
days is in strictly increasing order.
costs.length == 3
1 <= costs[i] <= 1000

Related LeetCode Problems

Practice more problems similar to Minimum Cost For Tickets.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.