- 题目:给定一个 24 小时制(小时:分钟 “HH:MM”)的时间列表,找出列表中任意两个时间的最小时间差并以分钟数表示。
输入:timePoints = ["23:59","00:00"]
输出:1
输入:timePoints = ["00:00","23:59","00:00"]
输出:0
class Solution(object):
def findMinDifference(self, timePoints):
"""
:type timePoints: List[str]
:rtype: int
"""
list = []
for i in range(len(timePoints)):
mi = int(timePoints[i][0]) * 600 + int(timePoints[i][1]) * 60 \
+ int(timePoints[i][3]) * 10 + int(timePoints[i][4]) * 1
list.append(mi)
list.sort()
list1 = []
for i in range(len(list) - 1):
list1.append(list[i + 1] - list[i])
list1.append(list[0] - list[len(list) - 1] + 1440)
list1.sort()
return list1[0]