Minimum Cost For Tickets
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You will travel on the days listed in days (strictly increasing integers between 1 and 365). Travel passes come in three kinds, with prices given by costs:
- costs[0] buys a 1-day pass,
- costs[1] buys a 7-day pass,
- costs[2] buys a 30-day pass.
A pass bought for day d covers days d through d + length - 1 inclusive. Return the minimum total amount you must spend so that every travel day is covered. Prices are not guaranteed to be monotonic (a longer pass may be cheaper).
Examples
Constraints
- 1 <= days.length <= 365
- 1 <= days[i] <= 365
- days is strictly increasing
- costs.length == 3
- 1 <= costs[i] <= 1000
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.