Class Solution
-
- All Implemented Interfaces:
public final class Solution1904 - The Number of Full Rounds You Have Played.
Medium
You are participating in an online chess tournament. There is a chess round that starts every
15minutes. The first round of the day starts at00:00, and after every15minutes, a new round starts.For example, the second round starts at
00:15, the fourth round starts at00:45, and the seventh round starts at01:30.
You are given two strings
loginTimeandlogoutTimewhere:loginTimeis the time you will login to the game, andlogoutTimeis the time you will logout from the game.
If
logoutTimeis earlier thanloginTime, this means you have played fromloginTimeto midnight and from midnight tologoutTime.Return the number of full chess rounds you have played in the tournament.
Note: All the given times follow the 24-hour clock. That means the first round of the day starts at
00:00and the last round of the day starts at23:45.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.
Constraints:
loginTimeandlogoutTimeare in the formathh:mm.00 <= hh <= 2300 <= mm <= 59loginTimeandlogoutTimeare not equal.
-
-
Constructor Summary
Constructors Constructor Description Solution()
-
Method Summary
Modifier and Type Method Description final IntegernumberOfRounds(String loginTime, String logoutTime)-
-
Method Detail
-
numberOfRounds
final Integer numberOfRounds(String loginTime, String logoutTime)
-
-
-
-