Minimum Difference Between Two Clock Times
Problem statement
Each input is a lowercase 12-hour clock time in the form h:mmam or h:mmpm. Return the smaller number of minutes separating the two readings on a 24-hour clock.
Function
minimumTimeDifference(first: String, second: String) → intExamples
Example 1
first = "11:30pm"second = "3:00pm"return = 510The same-day separation is eight hours and thirty minutes.
Example 2
first = "11:50pm"second = "12:10am"return = 20The shorter separation crosses midnight.
Constraints
- Both inputs are valid normalized 12-hour times.
Source note: Author-written prompt excerpt retained for source fidelity.