Leetcode Problem 1736. Latest Time by Replacing Hidden Digits

1736. Latest Time by Replacing Hidden Digits

Leetcode Solutions

Greedy Approach for Latest Valid Time

  1. Check the first character (hour tens place). If it's ?, decide between 2 or 1 based on the second character.
  2. Check the second character (hour ones place). If it's ?, decide between 3 or 9 based on the first character.
  3. Check the third character (minute tens place). If it's ?, replace it with 5.
  4. Check the fourth character (minute ones place). If it's ?, replace it with 9.
  5. Return the modified time string.
UML Thumbnail

Brute Force Approach for Latest Valid Time

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...