539 - Minimum Time Difference
Written on December 26, 2019
Tweet
Given a list of 24-hour clock time points in “Hour:Minutes” format, find the minimum minutes difference between any two time points in the list.
class Solution:
def findMinDifference(self, timePoints: List[str]) -> int:
def to_min(time):
return 60 * int(time[:2]) + int(time[3:])
mins = sorted((map(to_min, timePoints)))
mins.append(60 * 24 + mins[0])
return min([b - a for a, b in zip(mins, mins[1:])])