Maximize time by replacing ' _ ' in a given 24 Hour format time | Function to find the maximum time possible by replacing each ' _ ' with any digit ; If the first character is ' _ ' ; If s [ 1 ] is ' _ ' or s [ 1 ] is less than 4 ; Update s [ 0 ] as 2 ; Otherwise , update s [ 0 ] = 1 ; If s [ 1 ] is equal to ' _ ' ; If s [ 0 ] is equal to '2' ; Otherwise ; If S [ 3 ] is equal to ' _ ' ; If s [ 4 ] is equal to ' _ ' ; Print the modified string ; Driver Code
function maximumTime ( str ) { var s = str . split ( " " ) ; if ( s [ 0 ] == ' ' ) { if ( ( s [ 1 ] == ' ' ) || ( s [ 1 ] >= ' ' && s [ 1 ] < ' ' ) ) { s [ 0 ] = ' ' ; } else { s [ 0 ] = ' ' ; } } if ( s [ 1 ] == ' ' ) { if ( s [ 0 ] == ' ' ) { s [ 1 ] = ' ' ; } else { s [ 1 ] = ' ' ; } } if ( s [ 3 ] == ' ' ) { s [ 3 ] = ' ' ; } if ( s [ 4 ] == ' ' ) { s [ 4 ] = ' ' ; } for ( var i = 0 ; i < s . length ; i ++ ) document . write ( s [ i ] ) ; } var S = " " ; maximumTime ( S ) ;