1904. The Number of Full Rounds You Have Played
https://leetcode.com/problems/the-number-of-full-rounds-you-have-played
Description
A new online video game has been released, and in this video game, there are 15-minute rounds scheduled every quarter-hour period. This means that at HH:00
, HH:15
, HH:30
and HH:45
, a new round starts, where HH
represents an integer number from 00
to 23
. A 24-hour clock is used, so the earliest time in the day is 00:00
and the latest is 23:59
.
Given two strings startTime
and finishTime
in the format "HH:MM"
representing the exact time you started and finished playing the game, respectively, calculate the number of full rounds that you played during your game session.
For example, if
startTime = "05:20"
andfinishTime = "05:59"
this means you played only one full round from05:30
to05:45
. You did not play the full round from05:15
to05:30
because you started after the round began, and you did not play the full round from05:45
to06:00
because you stopped before the round ended.
If finishTime
is earlier than startTime
, this means you have played overnight (from startTime
to the midnight and from midnight to finishTime
).
Return the number of full rounds that you have played if you had started playing at startTime
and finished at finishTime
.
Example 1:
Example 2:
Example 3:
Constraints:
startTime
andfinishTime
are in the formatHH:MM
.00 <= HH <= 23
00 <= MM <= 59
startTime
andfinishTime
are not equal.
ac
Last updated