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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 21:40, gaby06
Simon says is a memory game where "simon" outputs a sequence of 10 characters (r, g, b, y) and the user must repeat the sequence. create a for loop that compares the two strings. for each match, add one point to user_score. upon a mismatch, end the game. sample output with inputs: 'rrgbryybgy' 'rrgbbrybgy'
Answers: 3
image
Computers and Technology, 24.06.2019 02:10, sIatt
Consider the usual algorithm to convert an infix expression to a postfix expression. suppose that you have read 10 input characters during a conversion and that the stack now contains these symbols: (5 points) | | | + | | ( | bottom |_*_| now, suppose that you read and process the 11th symbol of the input. draw the stack for the case where the 11th symbol is
Answers: 2
image
Computers and Technology, 24.06.2019 03:30, etxchrissy
What is the purpose of a computer network needs assessment? to analyze which workers need more training to improve their performance to compare worker productivity to determine what steps employees can take to increase company revenue to evaluate how to move from the current status to the desired goal
Answers: 2
image
Computers and Technology, 25.06.2019 07:50, hayleneolide
Identify an advantage of centralized processing
Answers: 1
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 in other subjects: