FastPrepFastPrep
Problem Brief

Maximum Time

INTERNOA
See Google online assessment and hiring insights

You are given a string that represents time in the format hh:mm. Some of the digits are blank (represented by ?). Fill in ? such that the time represented by this string is the maximum possible. Maximum time: 23:59, minimum time: 00:00. You can assume that input string is always valid.

1Example 1

Input
time = "?4:5?"
Output
"14:59"
Explanation
Provided by Groot for reference (May not be 100% accurate πŸ‘‰πŸ‘ˆ) - Replace the first '?' with '1' to make the hour as large as possible, which is '14'. The last '?' is replaced with '9' to make the minutes as large as possible, resulting in "14:59".

2Example 2

Input
time = "23:5?"
Output
"23:59"
Explanation
Provided by Groot for reference (May not be 100% accurate πŸ‘‰πŸ‘ˆ) - The hour is already at its maximum, '23'. Replace the last '?' with '9' to make the minutes as large as possible, resulting in "23:59".

3Example 3

Input
time = "?2:22"
Output
"23:22"
Explanation
Provided by Groot for reference (May not be 100% accurate πŸ‘‰πŸ‘ˆ) - Replace the first '?' with '2' to make the hour as large as possible, which is '23'. The minutes are already given, so the final time is "23:22".

4Example 4

Input
time = "0?:??"
Output
"09:59"
Explanation
Provided by Groot for reference (May not be 100% accurate πŸ‘‰πŸ‘ˆ) - Replace the second '?' with '9' to make the hour as large as possible, which is '09'. Replace the last two '?'s with '59' to make the minutes as large as possible, resulting in "09:59".

5Example 5

Input
time = "??:??"
Output
"23:59"
Explanation
Provided by Groot for reference (May not be 100% accurate πŸ‘‰πŸ‘ˆ) - Replace the first '?' with '2' and the second '?' with '3' to make the hour as large as possible, which is '23'. Replace the last two '?'s with '59' to make the minutes as large as possible, resulting in "23:59".

Constraints

Limits and guarantees your solution can rely on.

Unknown yet. If u happen to know about it feel free to lmk. tysm! ~^~
public String maximumTime(String time) {
    // write your code here
}
Input

time

"?4:5?"

Output

"14:59"

Sign in to submit your solution.