Drill

ProblemsPython › events

How many minutes between two clock times

easyeventsPython

Two timestamps on the same day: return the signed forward distance in minutes, wrapping past midnight.

hours_between(start_minutes: int, end_minutes: int) → int

Solve it in the editor →

Where you start

def hours_between(start_minutes: int, end_minutes: int) -> int:
    

Worked examples

CallResult
hours_between(0, 60)60
hours_between(60, 0)1380
hours_between(1400, 100)140
hours_between(0, 1440)0

Hint

Subtract, then add 1440 if the result is not positive, and take modulo 1440.

Reference solution in Python
def hours_between(start_minutes: int, end_minutes: int) -> int:
    diff = end_minutes - start_minutes
    return ((diff % 1440) + 1440) % 1440

The same problem in another language

More events problems in Python