#1904

The Number of Full Rounds You Have Played

expert · 1020 · lc medium +32 · verified · 43.5% accepted · 230 likes · top 25%

Description

A new chess round starts every 15 minutes (rounds begin at 00:00, 00:15, 00:30, ...). Given your loginTime and logoutTime in "HH:MM" format, return the number of complete chess rounds you participated in. If logoutTime is earlier than loginTime, you played across midnight.

Example 1:

Input: loginTime = "09:31", logoutTime = "10:14"
Output: 1
Explanation: You played one full round from 09:45 to 10:00.
You did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began.
You did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.

Example 2:

Input: loginTime = "21:30", logoutTime = "03:00"
Output: 22
Explanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00.
10 + 12 = 22.

Code

1
2
3