subject

Given a time (in 24-hour format) with missing digits marked as '?', we want to replace all of the question marks by the same digit (0-9) in such a way as to obtain the latest possible time. The earliest valid time is 00:00 and the latest valid time is 23:59. Write a function: class Solution { public String solution(String T); }
that, given a string T, returns the latest valid time as a string in the format "HH:MM", where HH denotes an hour in a two-digit 24-hour format and MM denotes minutes in a two-digit format.
Examples:
1. Given T = "2?:?8", the function should return "23:38".
2. Given T = "1?:?2", the function should return "15:52".
3. Given T = "??:??", the function should return "22:22".
4. Given T = "06:34", the function should return "06:34".
5. Given T = "1?:33", the function should return "19:33".
Assume that:
T consists of exactly five characters; the third one is ':'; the others are digits (0-9) or '?';
there always exists a valid time obtained by substituting '?' with digits.
In your solution, focus on correctness. The performance of your solution will not be the focus of the assessment.
Please use Python
import sys
def solution(T):
# Your solution goes here.
sys. stderr. write(
"Tip: Use sys. stderr. write() to write debug messages on the output tab.\n"
)
return T
def main():
# Read from stdin, solve the problem, write answer to stdout.
sys. stdout. write("\"%s\"" % (str(solution(sys. stdin. readline()[1:-1]

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:30
Hi plz 11 ! when planning a table, what step comes first: "define the column headers" or "calculate the number of columns/rows"? a. calculate the number of columns/rows b. define the column headers
Answers: 1
question
Computers and Technology, 22.06.2019 15:50
The file sales data.xlsx contains monthly sales amounts for 40 sales regions. write a sub that uses a for loop to color the interior of every other row (rows 3, 5, etc.) gray. color only the data area, columns a to m. (check the file colors in excel.xlsm to find a nice color of gray.)
Answers: 2
question
Computers and Technology, 22.06.2019 19:00
Which parts of a presentation should be the most general? a. introduction and conclusion b. introduction and outline c. outline and conclusion d. outline and body
Answers: 1
question
Computers and Technology, 22.06.2019 22:30
Jason needs to learn a new web tool. he went through his books to understand more about it. now he wants hands-on experience with using that tool. what would him? jason can use websites where workspace is provided to test the results of your code.
Answers: 2
You know the right answer?
Given a time (in 24-hour format) with missing digits marked as '?', we want to replace all of the qu...
Questions
question
Physics, 30.06.2019 13:50
question
Chemistry, 30.06.2019 13:50
Questions on the website: 13722363