Shortest gap

Write code · Challenge · §6.2 Neighbors after sorting

times holds the times when posts were uploaded during one day, as strings in the form "HH:MM". The times are not necessarily given in order.

Complete the function solution, which returns the length of the shortest gap, in minutes, between the upload times of any two posts. If two or more posts were uploaded at the same time, the answer is 0.

Gaps are measured only within the same day. So the gap between "23:59" and "00:00" is 1439 minutes. It is not measured as 1 minute across midnight.

Function

solution(times)

Constraints

Examples

timesresult
['09:15', '09:05', '10:00']10
['23:59', '00:00']1439

Starter code

def solution(times):
    answer = 0
    return answer

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.