Skip to content

Commit

Permalink
leetcode latest time
Browse files Browse the repository at this point in the history
  • Loading branch information
ferhatelmas committed Apr 16, 2024
1 parent b694f5c commit a494f1c
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions leetcode/algorithms/easy/latest_time.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
class Solution:
def findLatestTime(self, s: str) -> str:
r = ""
for i, e in enumerate(s):
if e != "?" or e == ":":
r += e
continue
if i == 0:
r += "1" if s[1] in "?01" else "0"
elif i == 1:
r += "1" if r[0] == "1" else "9"
elif i == 3:
r += "5"
else:
r += "9"
return r

0 comments on commit a494f1c

Please sign in to comment.