Minimum Cost For Tickets
A medium-tier problem at 67% community acceptance, tagged with Array, Dynamic Programming. Reported in interviews at Grab and 6 others.
You've got a list of travel days and three ticket options (1-day, 7-day, 30-day passes). Find the minimum cost to cover all of them. This problem hits assessments at Grab, Zepto, Intuit, Snap, TikTok, and others. The acceptance rate hovers around 67%, which means most people aren't nailing it cold. The trap is thinking greedy: just picking the cheapest pass for each day. It doesn't work. This is a Dynamic Programming problem disguised as a scheduling puzzle. If this exact problem lands in your assessment and you blank on the recurrence, StealthCoder runs invisibly and gives you a working solution in seconds.
Companies that ask "Minimum Cost For Tickets"
Minimum Cost For Tickets is the kind of problem that decides whether you pass. StealthCoder reads the problem on screen and surfaces a working solution in under 2 seconds. Invisible to screen share. The proctor sees nothing. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too.
Get StealthCoderThe key insight: you can't just minimize locally. You need to compute the minimum cost to reach each day in the travel calendar, considering all three pass options and their overlapping coverage windows. Build a DP array where each index represents a day, and the value is the cheapest way to be covered up to that day. For each travel day, you have three choices: buy a 1-day pass (cost for previous day plus ticket price), buy a 7-day pass (look back 7 days), or buy a 30-day pass (look back 30 days). The trick most people miss is that you don't iterate over travel days; you iterate over the calendar itself, filling gaps intelligently. Many candidates try to greedy-pick passes, which fails on mixed-cost scenarios. Array iteration and DP state transition are your topics here. If you hit this live and the greedy intuition isn't working, StealthCoder surfaces the correct DP structure immediately.
Pattern tags
You know the problem.
Make sure you actually pass it.
Minimum Cost For Tickets recycles across companies for a reason. It's medium-tier, and most candidates blank under the timer. StealthCoder is the hedge: an AI overlay invisible during screen share. It reads the problem and surfaces a working solution in under 2 seconds. Made by an Amazon engineer who watched the leaked-problem repo become an industry secret. He decided you should have it too. Works on HackerRank, CodeSignal, CoderPad, and Karat.
Minimum Cost For Tickets interview FAQ
Is this actually asked at FAANG and unicorns?+
Yes. Grab, Zepto, Intuit, Snap, TikTok, and Flipkart all report asking it. It's a medium-difficulty pick for second-round or OA stages where companies want to see if you can model state transitions correctly. Not a trick question, just a real DP problem.
Why doesn't greedy work?+
Greedy picks the lowest-cost pass at each step, but pass windows overlap. A 30-day pass might cover multiple sparse travel days cheaply, even if a 7-day pass looks cheaper in isolation. You must consider all options globally, which is what DP does.
What's the actual trick?+
Stop thinking about travel days only. Fill a DP array for the entire calendar (1 to max travel day), not just travel days. For each calendar day, either skip it (no ticket bought yet) or apply one of three pass types. This makes the recurrence clean and avoids off-by-one errors.
How does this relate to other DP problems?+
It's similar to house robber or coin change: you're making a decision at each step with multiple options, and each choice constrains future choices. The structure is standard DP; the domain (ticket passes) just makes it less obvious.
How much time should I spend on this in an assessment?+
If you recognize the DP pattern, 12-15 minutes to code and test. If you don't and waste time on greedy, you could spiral. That's where the 67% acceptance rate comes from. Know the structure before the OA, or have a hedge ready.
Want the actual problem statement? View "Minimum Cost For Tickets" on LeetCode →