Skip to content

Practice Minimum Cost to Set Cooking Time

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2162
LeetCode Problem

Minimum Cost to Set Cooking Time

Problem Statement

Set a cooking time using one to four decimal digits, padded on the left with zeros to four digits. The first two give minutes and the last two seconds; either field may be 00 through 99, and the total must be at least one second. Your finger starts at startAt. Moving to another digit costs moveCost and pressing a digit costs pushCost. Return the least cost to enter a representation totaling targetSeconds, using 60 seconds per minute.

Source: Minimum Cost to Set Cooking Time on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
startAt = 1, moveCost = 2, pushCost = 1, targetSeconds = 600
Output
6

# Example 2

Input
startAt = 0, moveCost = 1, pushCost = 2, targetSeconds = 76
Output
6

Constraints

0 <= startAt <= 9
1 <= moveCost, pushCost <= 10^5
1 <= targetSeconds <= 6039

Related LeetCode Problems

Practice more problems similar to Minimum Cost to Set Cooking Time.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.