Leetcode 539 Solution

This article provides solution to leetcode question 539 (minimum-time-difference)

https://leetcode.com/problems/minimum-time-difference

Solution

class Solution: def findMinDifference(self, timePoints: List[str]) -> int: a = [] for timePoint in timePoints: h, m = timePoint.split(":") h = int(h) m = int(m) a.append(h * 60 + m)
a.sort()
ans = 24 * 60 + a[0] - a[-1] for i in range(len(a) - 1): ans = min(ans, int(abs(a[i] - a[i + 1]))) return ans