class Solution:
"""
@param newTime: new time
@return: maximum time
"""
'''
大致思路:
1.时具有特殊性
如果首位是?的话,则进行看第二位是什么值,如果第二位是?,则返回23.如果第二位是大于3的话,则首位只能是为1.如果是小于3的话,首位为2
如果第二位是?的话,则需要看首位是什么值,如果首位小于2,则返回9。如果首位为2,则返回3
后面的分,直接返回:59即可
'''
def timeMagic(self,newTime):
h,m = '',''if newTime[0] == '?':
if newTime[1] == '?':
h = '23'
elif newTime[1] > '3':
h = '1'+ newTime[1]
elif newTime[1] <= '3':
h = '2' + newTime[1]
if newTime[1] == '?':
if newTime[0] < '2':
h = newTime[0] + '9'
elif newTime[0] == '2':
h = '23'if newTime[3] == '?':
if newTime[4] == '?':
m = '59'else:
m = '5' + newTime[4]
if newTime[4] == '?':
if newTime[3] == '?':
m = '59'else:
m = newTime[3] + '9'if m == '':
m = newTime[3:5]
return newTime[:2] + ':' + m if h == ''else h + ':' + m