406. Minimum Time Difference
You receive a list of clock times time_points, each a string in 24-hour "HH:MM" format. Return the smallest difference, in minutes, between any two of them.
The clock is circular: the distance between two times is measured the short way around, so 23:59 and 00:00 are 1 minute apart, not 1439. The list may contain the same time twice — two identical times are 0 minutes apart.
Example 1:
Input: find_min_difference(["23:59", "00:00"])
Output: 1
Explanation: Going forward one minute from 23:59 wraps past midnight to 00:00, so the circular distance is 1.
Example 2:
Input: find_min_difference(["01:10", "03:25", "22:50"])
Output: 135
Explanation: In minutes since midnight the times are 70, 205, and 1370. The candidate gaps are 205 − 70 = 135, 1370 − 205 = 1165, and the wrap-around 1440 − 1370 + 70 = 140. The smallest is 135.
Constraints:
- 2 ≤ time_points.length ≤ 2 * 10⁴
- Each time point has the exact form "HH:MM" with 00 ≤ HH ≤ 23 and 00 ≤ MM ≤ 59
Hints:
"HH:MM" is clock arithmetic in disguise. Convert every time to a single integer — minutes since midnight, 0 to 1439 — before comparing anything.
After sorting the minute values, the smallest difference must be between two *adjacent* values — with one extra candidate: the wrap-around pair from the latest time forward to the earliest, which costs 1440 − last + first.
There are only 1440 distinct minutes in a day. More than 1440 time points forces a duplicate by the pigeonhole principle, so you can answer 0 without looking further.
▶ Run checks these sample cases. Submit also runs hidden edge cases.
Input: time_points = ["23:59", "00:00"]
Expected output: 1