Advertisement
Guest User

Untitled

a guest
Jan 18th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. class Solution(object):
  2.     def findMinDifference(self, timePoints):
  3.         """
  4.        :type timePoints: List[str]
  5.        :rtype: int
  6.        """
  7.         DAYINMINUTES = 24 * 60
  8.        
  9.         minutes = []
  10.         for t in timePoints:
  11.             hour, minute = t.split(":")
  12.             minutes.append(int(hour) * 60 + int(minute))
  13.         minutes.sort()
  14.        
  15.         minDiff = DAYINMINUTES
  16.         for i in range(0, len(minutes) - 1):
  17.             minDiff = min(minDiff, minutes[i+1] - minutes[i])
  18.            
  19.         overDayMinDiff = minutes[0] + (DAYINMINUTES - minutes[-1])
  20.         return min(minDiff, overDayMinDiff)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement