1904. The Number of Full Rounds You Have Played Medium
1/**
2 * [1904] The Number of Full Rounds You Have Played
3 *
4 * 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.
5 *
6 * For example, the second round starts at 00:15, the fourth round starts at 00:45, and the seventh round starts at 01:30.
7 *
8 * You are given two strings loginTime and logoutTime where:
9 *
10 * loginTime is the time you will login to the game, and
11 * logoutTime is the time you will logout from the game.
12 *
13 * If logoutTime is earlier than loginTime, this means you have played from loginTime to midnight and from midnight to logoutTime.
14 * Return the number of full chess rounds you have played in the tournament.
15 * 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.
16 *
17 * Example 1:
18 *
19 * Input: loginTime = "09:31", logoutTime = "10:14"
20 * Output: 1
21 * Explanation: You played one full round from 09:45 to 10:00.
22 * You did not play the full round from 09:30 to 09:45 because you logged in at 09:31 after it began.
23 * You did not play the full round from 10:00 to 10:15 because you logged out at 10:14 before it ended.
24 *
25 * Example 2:
26 *
27 * Input: loginTime = "21:30", logoutTime = "03:00"
28 * Output: 22
29 * Explanation: You played 10 full rounds from 21:30 to 00:00 and 12 full rounds from 00:00 to 03:00.
30 * 10 + 12 = 22.
31 *
32 *
33 * Constraints:
34 *
35 * loginTime and logoutTime are in the format hh:mm.
36 * 00 <= hh <= 23
37 * 00 <= mm <= 59
38 * loginTime and logoutTime are not equal.
39 *
40 */
41pub struct Solution {}
42
43// problem: https://leetcode.com/problems/the-number-of-full-rounds-you-have-played/
44// discuss: https://leetcode.com/problems/the-number-of-full-rounds-you-have-played/discuss/?currentPage=1&orderBy=most_votes&query=
45
46// submission codes start here
47
48impl Solution {
49 pub fn number_of_rounds(login_time: String, logout_time: String) -> i32 {
50 0
51 }
52}
53
54// submission codes end
55
56#[cfg(test)]
57mod tests {
58 use super::*;
59
60 #[test]
61 fn test_1904() {
62 }
63}
64
Back
© 2025 bowen.ge All Rights Reserved.