539. Minimum Time Difference 最小时间差

# 题目描述：

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.

``````Example 1:
Input: ["23:59","00:00"]
Output: 1
``````

Note:

1. The number of time points in the given list is at least 2 and won't exceed 20000.
2. The input time is legal and ranges from 00:00 to 23:59.

# 解题方法

``````>>> a = [1,2,3]
>>> b = [4,5,6]
>>> c = [4,5,6,7,8]
>>> zipped = zip(a,b)     # 打包为元组的列表
[(1, 4), (2, 5), (3, 6)]
>>> zip(a,c)              # 元素个数与最短的列表一致
[(1, 4), (2, 5), (3, 6)]
>>> zip(*zipped)          # 与 zip 相反，可理解为解压，返回二维矩阵式
[(1, 2, 3), (4, 5, 6)]
``````

``````class Solution(object):
def findMinDifference(self, timePoints):
"""
:type timePoints: List[str]
:rtype: int
"""
def convert(time):
return int(time[:2]) * 60 + int(time[3:])
timePoints = map(convert, timePoints)
timePoints.sort()
return min((y - x) % (24 * 60)  for x, y in zip(timePoints, timePoints[1:] + timePoints[:1]))
``````

# 日期

2018 年 5 月 31 日 ———— 太阳暴晒，明天就要过儿童节了。激动