FastPrepMinimum Cost for Tickets
Problems/Minimum Cost for Tickets

Minimum Cost for Tickets

Roku logoRoku● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The interview report names the canonical exercise directly. The judged task matches the reported problem at about 99%.

You travel on every day listed in the strictly increasing array days. A travel pass is valid for 1, 7, or 30 consecutive calendar days, including its purchase day. Their costs are costs[0], costs[1], and costs[2].

Return the minimum total cost needed to cover every travel day.

Function

minTicketCost(days: int[], costs: int[]) → int

Examples

Example 1

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

Buy a 1-day pass on day 1, a 7-day pass on day 4, and a 1-day pass on day 20.

Example 2

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

A 30-day pass starting on day 1 covers days 1 through 30, and a 1-day pass covers day 31.

Constraints

  • 1 ≤ days.length ≤ 365
  • 1 ≤ days[i] ≤ 365
  • days is strictly increasing.
  • costs.length == 3
  • 1 ≤ costs[i] ≤ 1000

More Roku Onsite Interview questions

  • Max Area of IslandONSITE INTERVIEW · Seen Apr 2025

Similar questions at other companies

  • Longest Increasing SubsequenceAmazon · ONSITE INTERVIEW
  • Minimum Removals for a Nice ArrayAdobe · ONSITE INTERVIEWAdobe interview questions
  • Longest Increasing SubsequenceMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Longest Increasing SubsequenceExpedia · ONSITE INTERVIEWExpedia interview questions
  • Longest Increasing SubsequencePeopleStrong · ONSITE INTERVIEWPeopleStrong interview questions
  • Maximum Total Length of Non-Overlapping IntervalsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Russian Doll EnvelopesGoogle · ONSITE INTERVIEWGoogle interview questions
  • Russian Doll EnvelopesInMobi · ONSITE INTERVIEWInMobi interview questions
  • Russian Doll EnvelopesAirbnb · ONSITE INTERVIEWAirbnb interview questions
  • Longest Increasing SubsequenceByteDance · PHONE SCREENByteDance interview questions
All Roku interview questionsSee Roku hiring insights
Saved
class Solution {
    public int minTicketCost(int[] days, int[] costs) {
        // Write your code here.
    }
}
Checking account…