classSolution:defmincostTickets(self,days: List[int],costs: List[int]) ->int: dayset =set(days) m =max(days) costTable ={1: costs[0],7: costs[1],30: costs[2]} memo ={}defdp(day):if day notin memo:if day > m: memo[day]=0elif day in dayset: memo[day]=min([dp(day + key) + val for key, val in costTable.items()])else: memo[day]=dp(day+1)return memo[day]returndp(1)