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 17:30
Type the correct answer in the box. spell all words correctly. under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 3
question
Computers and Technology, 23.06.2019 09:30
Write an essay on online collaboration, how to do it, the challenges, resolving the challenges, and consider whether the risks are greater than rewards. ( need )
Answers: 1
question
Computers and Technology, 24.06.2019 02:00
Read the following scenario, and then answer the question below. you want to send an e-mail to your boss requesting a meeting to discuss a raise. what is the best example of an e-mail to an employer about this meeting? “hey jason. can we chat about getting me more money soon? let me know. peace, meg.” “hello jason. pardon me for sending yet another e-mail today about my need to talk to you about my position and a possible pay increase. i am dying to know when you can talk. sincerely, meg.” “hello jason. i have been with the company for one year and have taken on more responsibilities than outlined in my job description. i would appreciate an opportunity to speak with you about my position. let me know when we can schedule a meeting. you, meg.” “greetings jason! i hope this e-mail finds you well and happy today. i really, really want to talk to you about something important. i am not sure if you have time. i hope you do. get back in touch with me and let me know when we might talk. ever so much for taking the time to read this. sincerely, meg.”
Answers: 3
question
Computers and Technology, 24.06.2019 07:30
Jason is working on a microsoft excel worksheet and he wants to create a print preview shortcut. his teacher asks him to access the customization option to create the new shortcut. which two tabs should jason select to place the print preview shortcut on the worksheet toolbar? a. new tab (custom) and new group (custom) b. new file tab (custom) and new tab (custom) c. new custom group and new command d. new custom tab and new command
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
Mathematics, 26.06.2021 17:40
question
Computers and Technology, 26.06.2021 17:40
question
Geography, 26.06.2021 17:40
question
Geography, 26.06.2021 17:40
question
Mathematics, 26.06.2021 17:40
question
History, 26.06.2021 17:50
Questions on the website: 13722361