You have noticed that your digital clock does not show the correct current time. You know what the correct time is, so there should be no problem setting it. Your clock has two buttons - one is supposed to increment the hour by 1, and the other is supposed to increment the minute by 1. The hour is a two digit value between 00 and 23, inclusive, and the minute is a two digit value between 00 and 59, inclusive. The values wrap around, so pressing the hour button when the hour is 23 will change the hour to 00, and pressing the minute button when the minute is 59 will change the minute to 00. Pressing the hour button should never affect the minute value, and pressing the minute button should never affect the hour value (see note). However, the hour button on your clock is broken, and when pressed, increments both the hour and minute by 1. You want to find the minimal number of button presses needed to set the correct time on the clock.
For example, if the clock shows the time as 03:12 and you know the current time is 04:15, you should press the hour button once and the minute button twice for a total of three button presses. After pressing the hour button, the time changes to 04:13, and after pressing the minute button twice, the time changes to 04:15. You must perform the button presses immediately - you cannot wait until the time on the clock changes by itself.
You are given a String clockTime, the time shown on the clock, and a String currentTime, the correct current time, both formatted as "HH:MM" (quotes added for clarity), where HH is the hour value and MM is the minute value. |