Skip to content

Commit a5de8ea

Browse files
committed
1904. The Number of Full Rounds You Have Played: RETRY
1 parent d8cd55a commit a5de8ea

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed

src/solution/mod.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1435,3 +1435,4 @@ mod s1899_merge_triplets_to_form_target_triplet;
14351435
mod s1900_the_earliest_and_latest_rounds_where_players_compete;
14361436
mod s1901_find_a_peak_element_ii;
14371437
mod s1903_largest_odd_number_in_string;
1438+
mod s1904_the_number_of_full_rounds_you_have_played;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
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+
*/
41+
pub 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+
48+
impl 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)]
57+
mod tests {
58+
use super::*;
59+
60+
#[test]
61+
#[ignore]
62+
fn test_1904_example_1() {
63+
let login_time = "09:31".to_string();
64+
let logout_time = "10:14".to_string();
65+
66+
let result = 1;
67+
68+
assert_eq!(Solution::number_of_rounds(login_time, logout_time), result);
69+
}
70+
71+
#[test]
72+
#[ignore]
73+
fn test_1904_example_2() {
74+
let login_time = "21:30".to_string();
75+
let logout_time = "03:00".to_string();
76+
77+
let result = 22;
78+
79+
assert_eq!(Solution::number_of_rounds(login_time, logout_time), result);
80+
}
81+
}

0 commit comments

Comments
 (0)