2437. Number of Valid Clock Times Easy

@problem@discussion
#String#Enumeration



1/**
2 * [2437] Number of Valid Clock Times
3 *
4 * You are given a string of length 5 called time, representing the current time on a digital clock in the format "hh:mm". The earliest possible time is "00:00" and the latest possible time is "23:59".
5 * In the string time, the digits represented by the ? symbol are unknown, and must be replaced with a digit from 0 to 9.
6 * Return an integer answer, the number of valid clock times that can be created by replacing every ? with a digit from 0 to 9.
7 *  
8 * <strong class="example">Example 1:
9 * 
10 * Input: time = "?5:00"
11 * Output: 2
12 * Explanation: We can replace the ? with either a 0 or 1, producing "05:00" or "15:00". Note that we cannot replace it with a 2, since the time "25:00" is invalid. In total, we have two choices.
13 * 
14 * <strong class="example">Example 2:
15 * 
16 * Input: time = "0?:0?"
17 * Output: 100
18 * Explanation: Each ? can be replaced by any digit from 0 to 9, so we have 100 total choices.
19 * 
20 * <strong class="example">Example 3:
21 * 
22 * Input: time = "??:??"
23 * Output: 1440
24 * Explanation: There are 24 possible choices for the hours, and 60 possible choices for the minutes. In total, we have 24 * 60 = 1440 choices.
25 * 
26 *  
27 * Constraints:
28 * 
29 * 	time is a valid string of length 5 in the format "hh:mm".
30 * 	"00" <= hh <= "23"
31 * 	"00" <= mm <= "59"
32 * 	Some of the digits might be replaced with '?' and need to be replaced with digits from 0 to 9.
33 * 
34 */
35pub struct Solution {}
36
37// problem: https://leetcode.com/problems/number-of-valid-clock-times/
38// discuss: https://leetcode.com/problems/number-of-valid-clock-times/discuss/?currentPage=1&orderBy=most_votes&query=
39
40// submission codes start here
41
42impl Solution {
43    pub fn count_time(time: String) -> i32 {
44        0
45    }
46}
47
48// submission codes end
49
50#[cfg(test)]
51mod tests {
52    use super::*;
53
54    #[test]
55    fn test_2437() {
56    }
57}
58


Back
© 2025 bowen.ge All Rights Reserved.