Skip to content

Practice Minimum Time Difference

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#539
LeetCode Problem

Minimum Time Difference

Problem Statement

Each item in timePoints is a valid 24-hour clock reading in HH:MM format. Find the smallest gap, in minutes, between any pair. Treat the clock as circular: midnight immediately follows 23:59. Repeated readings have a gap of zero. Practice approach: Convert hours and minutes to minutes since midnight, then sort. Compare adjacent readings and the wraparound gap from the final reading to the first plus 1440. Sorting takes O(n log n) time; a 1440-slot presence array also works.

Source: Minimum Time Difference on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
timePoints = ["23:50", "00:05", "12:00"]
Output
15
Explanation

The shortest route crosses midnight: ten minutes to midnight and five after it.

Constraints

2 <= timePoints.length <= 20000
Every entry uses valid HH:MM notation.

Related LeetCode Problems

Practice more problems similar to Minimum Time Difference.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.