Maximum possible number with the given operation | Function to return the maximum possible integer that can be obtained from the given integer after performing the given operations ; For every digit ; Digits greater than or equal to 5 need not to be changed as changing them will lead to a smaller number ; The resulting integer cannot have leading zero ; Driver code
function maxInt ( str ) { var str2 = " " ; for ( var i = 0 ; i < str . length ; i ++ ) { if ( str [ i ] < ' ' ) { var l = ( ' ' . charCodeAt ( 0 ) - str [ i ] . charCodeAt ( 0 ) ) + ' ' . charCodeAt ( 0 ) ; str2 = str2 . concat ( String . fromCharCode ( l ) ) ; } } if ( str2 [ 0 ] == ' ' ) str2 [ 0 ] = ' ' ; return str2 ; } var str = " " ; document . write ( maxInt ( str ) )