Leetcode 1736. Latest Time by Replacing Hidden Digits | | Leetcode 1736. Latest Time by Replacing Hidden Digits 文章作者:Tyan博客:noahsnail.com | CSDN | 简书 1. Description 2. Solution解析:枚举所有可能情况,替换对应的?即可。 Version 1 1234567891011121314151617181920class Solution: def maximumTime(self, time: str) -> str: result = '' if time[0] == '?': if time[1] < '4' or time[1] == '?': result += '2' else: result += '1' else: result += time[0] if time[1] == '?': result += '9' if result[-1] < '2' else '3' else: result += time[1] result += ':' result += '5' if time[3] == '?' else time[3] result += '9' if time[4] == '?' else time[4] return result Reference https://leetcode.com/problems/latest-time-by-replacing-hidden-digits/ 如果有收获,可以请我喝杯咖啡! 赏 微信打赏 支付宝打赏