1904. The Number of Full Rounds You Have Played LeetCode Solution
In this guide, you will get 1904. The Number of Full Rounds You Have Played LeetCode Solution with the best time and space complexity. The solution to The Number of Full Rounds You Have Played problem is provided in various programming languages like C++, Java, and Python. This will be helpful for you if you are preparing for placements, hackathons, interviews, or practice purposes. The solutions provided here are very easy to follow and include detailed explanations.
Table of Contents
- Problem Statement
- Complexity Analysis
- The Number of Full Rounds You Have Played solution in C++
- The Number of Full Rounds You Have Played solution in Java
- The Number of Full Rounds You Have Played solution in Python
- Additional Resources

Problem Statement of 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, and
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:
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:
loginTime and logoutTime are in the format hh:mm.
00 <= hh <= 23
00 <= mm <= 59
loginTime and logoutTime are not equal.
Complexity Analysis
- Time Complexity: O(1)
- Space Complexity: O(1)
1904. The Number of Full Rounds You Have Played LeetCode Solution in C++
class Solution {
public:
int numberOfRounds(string loginTime, string logoutTime) {
const int start = getMinutes(loginTime);
int finish = getMinutes(logoutTime);
if (start > finish)
finish += 60 * 24;
return max(0, finish / 15 - (start + 14) / 15);
}
private:
int getMinutes(const string& time) {
const int h = stoi(time.substr(0, 2));
const int m = stoi(time.substr(3));
return 60 * h + m;
}
};
/* code provided by PROGIEZ */
1904. The Number of Full Rounds You Have Played LeetCode Solution in Java
class Solution {
public int numberOfRounds(String loginTime, String logoutTime) {
final int start = getMinutes(loginTime);
int finish = getMinutes(logoutTime);
if (start > finish)
finish += 60 * 24;
return Math.max(0, finish / 15 - (start + 14) / 15);
}
private int getMinutes(final String s) {
return 60 * Integer.valueOf(s.substring(0, 2)) + Integer.valueOf(s.substring(3));
}
}
// code provided by PROGIEZ
1904. The Number of Full Rounds You Have Played LeetCode Solution in Python
class Solution:
def numberOfRounds(self, loginTime: str, logoutTime: str) -> int:
start = self._getMinutes(loginTime)
finish = self._getMinutes(logoutTime)
if start > finish:
finish += 60 * 24
return max(0, finish // 15 - (start + 14) // 15)
def _getMinutes(self, time: str) -> int:
h, m = map(int, time.split(':'))
return 60 * h + m
# code by PROGIEZ
Additional Resources
- Explore all LeetCode problem solutions at Progiez here
- Explore all problems on LeetCode website here
Happy Coding! Keep following PROGIEZ for more updates and solutions.