LC 983 - Minimum Cost For Tickets

Approach [translate by ChatGPT] This problem gives a list of travel days (days) and the costs of 1-day, 7-day, and 30-day passes. We need the minimum cost to cover all travel days. This clearly suggests a DP solution. My first idea was to maintain an ansAry where each entry stores the optimal cost up to day i. For each day, we check day-1, day-7, and day-30 and take the minimum. ...

January 4, 2025 · 3 min