Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost For Tickets

med
30 min
Try to solve the Minimum Cost For Tickets problem.

Statement

You are given a list days, where days[i] represents a calendar day on which you plan to travel. You are also given travel pass costs for three different durations:

  • A 11-day pass costs costs[0].

  • A 77-day pass costs costs[1].

  • A 3030-day pass costs costs[2].

A pass bought on day dd covers travel starting from day dd and continues for its full duration. For example, a 77-day pass bought on day dd covers days dd through d+6d + 6.

Return the minimum total cost needed to cover all travel days in days.

Constraints:

  • 11 \leq days.length 365\leq 365

  • 11 \leq days[i] 365\leq 365

  • days is in strictly increasing order

  • costs.length ==3== 3

  • 11 \leq costs[i] 1000\leq 1000

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost For Tickets

med
30 min
Try to solve the Minimum Cost For Tickets problem.

Statement

You are given a list days, where days[i] represents a calendar day on which you plan to travel. You are also given travel pass costs for three different durations:

  • A 11-day pass costs costs[0].

  • A 77-day pass costs costs[1].

  • A 3030-day pass costs costs[2].

A pass bought on day dd covers travel starting from day dd and continues for its full duration. For example, a 77-day pass bought on day dd covers days dd through d+6d + 6.

Return the minimum total cost needed to cover all travel days in days.

Constraints:

  • 11 \leq days.length 365\leq 365

  • 11 \leq days[i] 365\leq 365

  • days is in strictly increasing order

  • costs.length ==3== 3

  • 11 \leq costs[i] 1000\leq 1000

Unlock AI-Powered LearningUpgrade to smarter learning with instant explanations of Ask Agent, Personalized Interview Prep, Real-World Projects, 3 AI Mock Interviews per month, and Personalized Paths