Mid/SeniorMathString

The Number of Full Rounds You Have Played

You are participating in an online chess tournament. There is a chess round that starts every 15 minutes. The first round of the day starts at 00:00, and after every 15 minutes, a new round starts.

  • For example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.

You are given two strings loginTime and logoutTime where:

  • loginTime is the time you will login to the game.
  • logoutTime is the time you will logout from the game.

If logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.

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:00 and the last round of the day starts at 23:45.

Example 1
InputloginTime = "09:31", logoutTime = "10:14"
Output1
You played one full round from 09:45 to 10:00, while the adjacent rounds were incomplete because you logged in after one began and logged out before the next ended.
Example 2
InputloginTime = "21:30", logoutTime = "03:00"
Output22
You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00, for a total of 22.

Constraints

  • loginTime and logoutTime are in the format hh:mm.
  • 00 <= hh <= 23
  • 00 <= mm <= 59
  • loginTime and logoutTime are not equal.

Asked at 1 companies

</>

Your Solution

(Ctrl/Cmd + Enter)

Switching Language

Loading template...

Loading...

Sign in to save your progress

AI code evaluation

Get a correctness verdict, missed edge cases, and complexity analysis of your solution.

Sign in to evaluate