Python O(nlogn) Time O(1) space


  • 0
    E
        def findMinDifference(self, timePoints):
            """
            :type timePoints: List[str]
            :rtype: int
            """
            for i,v in enumerate(timePoints):
                timePoints[i] = int(v[:2])*60 + int(v[-2:])
            timePoints.sort()
            mn = 1440
            for i in range(len(timePoints)-1): 
                mn = min(mn, timePoints[i+1]-timePoints[i])
            return min(mn, timePoints[0]+1440 - timePoints[-1])
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.