Minimum Time Difference
MediumMathmath
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
You are given a list timePoints of clock times in 24-hour "HH:MM" format. The clock wraps around, so "23:59" and "00:00" are one minute apart.
Return the smallest difference, in minutes, between any two times in the list. Identical times have a difference of 0.
Examples
Input: timePoints = ["23:59","00:00"]
Output: 1
Going forward from 23:59 across midnight reaches 00:00 in one minute.
Input: timePoints = ["00:00","23:59","00:00"]
Output: 0
00:00 appears twice.
Constraints
- 2 <= timePoints.length <= 2 * 10^4
- Every entry is a valid time from "00:00" to "23:59".
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.