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 09:50
Assume that you have an sorted array of records. assume that the length of the array (n) is known. give two different methods to search for a specific value in this array. you can use english or pseudo-code for your algorithm. what is the time complexity for each algorithm and why?
Answers: 1
question
Computers and Technology, 23.06.2019 01:30
For a typical middle-income family, what is the estimated cost of raising a child to the age of 18? $145,500 $245,340 $304,340 $455,500
Answers: 2
question
Computers and Technology, 23.06.2019 02:30
Research data that is presented using descriptive language is said to be
Answers: 2
question
Computers and Technology, 23.06.2019 17:30
Scientists have changed the model of the atom as they have gathered new evidence. one of the atomic models is shown below. what experimental evidence led to the development of this atomic model from the one before it? a few of the positive particles aimed at a gold foil seemed to bounce back. the colors of light emitted from heated atoms had very specific energies. experiments with water vapor showed that elements combine in specific proportions. cathode rays were bent in the same way whenever a magnet was brought near them.
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
English, 27.05.2020 22:01
question
English, 27.05.2020 22:01
question
English, 27.05.2020 22:01
question
English, 27.05.2020 22:01
Questions on the website: 13722362