3114. Latest Time You Can Obtain After Replacing Characters Easy

@problem@discussion
#String#Enumeration



1/**
2 * [3114] Latest Time You Can Obtain After Replacing Characters
3 *
4 * You are given a string s representing a 12-hour format time where some of the digits (possibly none) are replaced with a "?".
5 * 12-hour times are formatted as "HH:MM", where HH is between 00 and 11, and MM is between 00 and 59. The earliest 12-hour time is 00:00, and the latest is 11:59.
6 * You have to replace all the "?" characters in s with digits such that the time we obtain by the resulting string is a valid 12-hour format time and is the latest possible.
7 * Return the resulting string.
8 *  
9 * <strong class="example">Example 1:
10 * <div class="example-block">
11 * Input: <span class="example-io">s = "1?:?4"</span>
12 * Output: <span class="example-io">"11:54"</span>
13 * Explanation: The latest 12-hour format time we can achieve by replacing "?" characters is "11:54".
14 * </div>
15 * <strong class="example">Example 2:
16 * <div class="example-block">
17 * Input: <span class="example-io">s = "0?:5?"</span>
18 * Output: <span class="example-io">"09:59"</span>
19 * Explanation: The latest 12-hour format time we can achieve by replacing "?" characters is "09:59".
20 * </div>
21 *  
22 * Constraints:
23 * 
24 * 	s.length == 5
25 * 	s[2] is equal to the character ":".
26 * 	All characters except s[2] are digits or "?" characters.
27 * 	The input is generated such that there is at least one time between "00:00" and "11:59" that you can obtain after replacing the "?" characters.
28 * 
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/latest-time-you-can-obtain-after-replacing-characters/
33// discuss: https://leetcode.com/problems/latest-time-you-can-obtain-after-replacing-characters/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38    pub fn find_latest_time(s: String) -> String {
39        String::new()
40    }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47    use super::*;
48
49    #[test]
50    fn test_3114() {
51    }
52}
53


Back
© 2025 bowen.ge All Rights Reserved.