Skip to content

Commit 22153e7

Browse files
authored
Create latest-time-you-can-obtain-after-replacing-characters.py
1 parent 3d21ec6 commit 22153e7

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Time: O(1)
2+
# Space: O(1)
3+
4+
# greedy
5+
class Solution(object):
6+
def findLatestTime(self, s):
7+
"""
8+
:type s: str
9+
:rtype: str
10+
"""
11+
result = list(s)
12+
if result[0] == '?':
13+
result[0] = '1' if result[1] == '?' or result[1] <= '1' else '0'
14+
if result[1] == '?':
15+
result[1] = '1' if result[0] == '1' else '9'
16+
if result[3] == '?':
17+
result[3] = '5'
18+
if result[4] == '?':
19+
result[4] = '9'
20+
return "".join(result)

0 commit comments

Comments
 (0)