Maximize the missing values in given time in HH : MM format | Function to find the maximum time by replacing ' ? ' by any digits ; If the 0 th index is '? ; If the 1 st index is '? ; If the 3 rd index is '? ; If the 4 th index is '? ; Return new string ; Driver Code
def maxTime ( s ) : NEW_LINE ' NEW_LINE INDENT s = list ( s ) NEW_LINE if ( s [ 0 ] == ' ? ' ) : NEW_LINE INDENT if ( s [ 1 ] <= '3' or s [ 1 ] == ' ? ' ) : NEW_LINE INDENT s [ 0 ] = '2' NEW_LINE DEDENT else : NEW_LINE INDENT s [ 0 ] = '1' NEW_LINE DEDENT DEDENT DEDENT ' NEW_LINE INDENT if ( s [ 1 ] == ' ? ' ) : NEW_LINE INDENT if ( s [ 0 ] != '2' ) : NEW_LINE INDENT s [ 1 ] = 9 NEW_LINE DEDENT else : NEW_LINE INDENT s [ 1 ] = 3 NEW_LINE DEDENT DEDENT DEDENT ' NEW_LINE INDENT if ( s [ 3 ] == ' ? ' ) : NEW_LINE INDENT s [ 3 ] = '5' NEW_LINE DEDENT DEDENT ' NEW_LINE INDENT if ( s [ 4 ] == ' ? ' ) : NEW_LINE INDENT s [ 4 ] = '9' NEW_LINE DEDENT print ( " " . join ( s ) ) NEW_LINE DEDENT S = " ? 4:5 ? " NEW_LINE maxTime ( S ) NEW_LINE