The Number of Full Rounds You Have Played
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:45, a new round starts, where
HH represents an integer number from
23. A 24-hour clock is used, so the earliest time in the day is
00:00 and the latest is
Given two strings
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"and
finishTime = "05:59"this means you played only one full round from
05:45. You did not play the full round from
05:30because you started after the round began, and you did not play the full round from
06:00because you stopped before the round ended.
finishTime is earlier than
startTime, this means you have played overnight (from
startTime to the midnight and from midnight to
Return the number of full rounds that you have played if you had started playing at
startTime and finished at
Input: startTime = "12:01", finishTime = "12:44" Output: 1 Explanation: You played one full round from 12:15 to 12:30. You did not play the full round from 12:00 to 12:15 because you started playing at 12:01 after it began. You did not play the full round from 12:30 to 12:45 because you stopped playing at 12:44 before it ended.
Input: startTime = "20:00", finishTime = "06:00" Output: 40 Explanation: You played 16 full rounds from 20:00 to 00:00 and 24 full rounds from 00:00 to 06:00. 16 + 24 = 40.
Input: startTime = "00:00", finishTime = "23:59" Output: 95 Explanation: You played 4 full rounds each hour except for the last hour where you played 3 full rounds.
finishTimeare in the format
00 <= HH <= 23
00 <= MM <= 59
finishTimeare not equal.
def numberOfRounds(self, startTime: str, finishTime: str) -> int: s = int(startTime[:2]) * 60 + int(startTime[-2:]) t = int(finishTime[:2]) * 60 + int(finishTime[-2:]) if s > t: t += 24 * 60 q, r = divmod(s, 15) s, t = q + int(r > 0), t // 15 return max(0, t - s)
June Long Challenge 2021 Solutions
- Maximum Frequent Subarray Sum solution codechef
- Dual Distance solution codechef
- Optimal Xor Set solution codechef
- Minimum Subtree Cover solution codechef
- Minimum Dual Area solution codechef
- Bitwise Tuples solution codechef
- Shortest Route solution codechef
- Bella ciao solution codechef
- Summer Heat solution codechef