[leetcode, JS] 1736. Latest Time by Replacing Hidden Digits

mxxn·2023년 11월 8일
0

leetcode

목록 보기
113/198

문제

문제 링크 : Latest Time by Replacing Hidden Digits

풀이

/**
 * @param {string} time
 * @return {string}
 */
var maximumTime = function(time) {
    time = time.split('')
    if (time[0] === "?") time[0] = time[1] > 3 ? "1" : "2"
    if (time[1] === "?") time[1] = time[0] > 1 ? "3" : "9"
    if (time[3] === "?") time[3] = "5"
    if (time[4] === "?") time[4] = "9"
    return time.join('')
};
  1. if문으로 나누어 가장 늦은 시간으로 만들기
  • Runtime 50ms, Memory 41.64MB
profile
내일도 글쓰기

0개의 댓글