Loading...
You are given an array days, a strictly increasing list of day numbers within a 365-day range that you must be covered on, and an array costs of three prices.
Three kinds of cover are sold. costs[0] buys 1 consecutive day, costs[1] buys 7 consecutive days, and costs[2] buys 30 consecutive days. A cover starting on day d spans days d through d + length - 1; you may buy covers starting on any day, and coverage may overlap or extend past days you don't need.
Return the minimum total cost so that every listed day is covered.
Input: days = [1,4,6,7,8,20], costs = [2,7,15]
Output: 11
Explanation: A 1-day cover on day 1 (cost 2), a 7-day cover starting day 3 (cost 7) spanning days 3-9, and a 1-day cover on day 20 (cost 2). Total 11.
Input: days = [1,2,3,4,5,6,7,8,9,10,30,31], costs = [2,7,15]
Output: 17
Explanation: A 30-day cover starting day 1 (cost 15) spans days 1-30, and a 1-day cover on day 31 (cost 2). Total 17.
days.length ≤365days[i] ≤365days is strictly increasing.costs.length == 3costs[i] ≤1000Click "Run" to test with sample cases or "Submit" to run all tests.