Class Solution
- java.lang.Object
-
- g2201_2300.s2224_minimum_number_of_operations_to_convert_time.Solution
-
public class Solution extends Object
2224 - Minimum Number of Operations to Convert Time.Easy
You are given two strings
currentandcorrectrepresenting two 24-hour times.24-hour times are formatted as
"HH:MM", whereHHis between00and23, andMMis between00and59. The earliest 24-hour time is00:00, and the latest is23:59.In one operation you can increase the time
currentby1,5,15, or60minutes. You can perform this operation any number of times.Return the minimum number of operations needed to convert
currenttocorrect.Example 1:
Input: current = “02:30”, correct = “04:35”
Output: 3
Explanation:
We can convert current to correct in 3 operations as follows:
-
Add 60 minutes to current. current becomes “03:30”.
-
Add 60 minutes to current. current becomes “04:30”.
-
Add 5 minutes to current. current becomes “04:35”.
It can be proven that it is not possible to convert current to correct in fewer than 3 operations.
Example 2:
Input: current = “11:00”, correct = “11:01”
Output: 1
Explanation: We only have to add one minute to current, so the minimum number of operations needed is 1.
Constraints:
currentandcorrectare in the format"HH:MM"current <= correct
-
-
-
Constructor Summary
Constructors Constructor Description Solution()
-