Skip to content

Latest commit

 

History

History
57 lines (45 loc) · 1.13 KB

_1736. Latest Time by Replacing Hidden Digits.md

File metadata and controls

57 lines (45 loc) · 1.13 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : June 03, 2024

Last updated : July 01, 2024


Related Topics : String, Greedy

Acceptance Rate : 42.715 %


Solutions

C

char* maximumTime(char* time) {
    // Hours
    if (time[0] == '?' && time[1] == '?') {
        time[0] = '2';
        time[1] = '3';
    } else if (time[0] == '?') {
        if (time[1] - '0' <= 3) {
            time[0] = '2';
        } else {
            time[0] = '1';
        }
    } else if (time[1] == '?') {
        if (time[0] == '2') {
            time[1] = '3';
        } else {
            time[1] = '9';
        }
    }

    // Minutes
    if (time[3] == '?') {
        time[3] = '5';
    }
    if (time[4] == '?') {
        time[4] = '9';
    }

    return time;
}