Lexicographical Maximum substring of string | JavaScript program to find the lexicographically maximum substring . ; loop to find the max leicographic substring in the substring array ; Driver code
function LexicographicalMaxString ( str ) { var mx = " " ; for ( var i = 0 ; i < str . length ; ++ i ) { if ( mx . localeCompare ( str . substring ( i ) ) <= 0 ) { mx = str . substring ( i ) ; } } return mx ; } var str = " " ; document . write ( LexicographicalMaxString ( str ) ) ;