# LeetCode: Latest Time By Replacing Hidden Digits Solution

```.css-ds3kc{display:table-row;}.css-1t8atru{display:table-cell;opacity:0.5;padding-right:var(--chakra-space-6);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;text-align:right;}1.css-2qghsv{display:table-cell;}var maximumTime = function (time) {2  const fillHour = hh => {3    let [t1, t2] = hh.split("")4
5    if (t1 === "?" && t2 === "?") {6      t1 = "2"7      t2 = "3"8    }9
10    if (t1 === "?") {11      if (Number(t2) > 3) {12        t1 = "1"13      } else {14        t1 = "2"15      }16    }17
18    if (t2 === "?") {19      if (Number(t1) <= 1) {20        t2 = "9"21      } else {22        t2 = "3"23      }24    }25
26    return t1 + t227  }28  const fillMin = mm => {29    let [t1, t2] = mm.split("")30
31    if (t1 === "?") {32      t1 = "5"33    }34
35    if (t2 === "?") {36      t2 = "9"37    }38
39    return t1 + t240  }41  const [hh, mm] = time.split(":")42  return fillHour(hh) + ":" + fillMin(mm)43}```

leetcode

## Next Post

LeetCode: Minimum Number Of People To Teach

Jan 24, 2021

Search Posts