Skip to content

Commit 993bae9

Browse files
authored
Create latest-time-by-replacing-hidden-digits.py
1 parent f3afe42 commit 993bae9

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Time: O(1)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def maximumTime(self, time):
6+
"""
7+
:type time: str
8+
:rtype: str
9+
"""
10+
result = list(time)
11+
for i, c in enumerate(time):
12+
if c != "?":
13+
continue
14+
if i == 0:
15+
result[i] = '2' if result[i+1] in "?0123" else '1'
16+
elif i == 1:
17+
result[i] = '3' if result[0] == '2' else '9'
18+
elif i == 3:
19+
result[i] = '5'
20+
elif i == 4:
21+
result[i] = '9'
22+
return "".join(result)

0 commit comments

Comments
 (0)