Minimum Cost to Set Cooking Time
A generic microwave supports cooking times for:
- at least
1second. - at most
99minutes and99seconds.
To set the cooking time, you push at most four digits. The microwave normalizes what you push as four digits by prepending zeroes. It interprets the first two digits as the minutes and the last two digits as the seconds. It then adds them up as the cooking time.
You are given integers startAt, moveCost, pushCost, and targetSeconds. Initially, your finger is on the digit startAt. Moving the finger above any specific digit costs moveCost units of fatigue. Pushing the digit below the finger once costs pushCost units of fatigue.
There can be multiple ways to set the microwave to cook for targetSeconds seconds, but you are interested in the way with the minimum cost.
Return the minimum cost to set targetSeconds seconds of cooking time.
Remember that one minute consists of 60 seconds.
startAt = 1, moveCost = 2, pushCost = 1, targetSeconds = 6006startAt = 0, moveCost = 1, pushCost = 2, targetSeconds = 766Constraints
- 0 <= startAt <= 9
- 1 <= moveCost, pushCost <= 10^5
- 1 <= targetSeconds <= 6039