Latest Time by Replacing Hidden Digits
קל
שאלה מראיונות עבודה ממאגר שאלות של LeetCode שאלה מספר 1736 נשאל ב: Checkpoint
You are given a string `time` in the form `hh:mm`, where some digits are hidden (represented by `?`). Return the latest valid time you can get by replacing the hidden digits.
פתרון קוד
JavaScript
Python
function maximumTime(time) {
const chars = time.split("");
if (chars[0] === "?") {
chars[0] = chars[1] === "?" || chars[1] <= "3" ? "2" : "1";
}
if (chars[1] === "?") {
chars[1] = chars[0] === "2" ? "3" : "9";
}
if (chars[3] === "?") {
chars[3] = "5";
}
if (chars[4] === "?") {
chars[4] = "9";
}
return chars.join("");
}הסבר וידאו כיצד לפתור את השאלה

לעבור את ראיון העבודה הבא שלך בהצלחה
קורס דיגיטלי מקיף עם +25 שיעורים מעשיים, כשעתיים של וידאו, וליווי של מראיין בכיר.