Lexicographical Maximum substring of string | C # program to find the lexicographically maximum substring . ; loop to find the max leicographic substring in the substring array ; Driver code
using System ; public class GFG { static String LexicographicalMaxString ( String str ) { String mx = " " ; for ( int i = 0 ; i < str . Length ; ++ i ) { if ( mx . CompareTo ( str . Substring ( i ) ) <= 0 ) { mx = str . Substring ( i ) ; } } return mx ; } public static void Main ( ) { String str = " ababaa " ; Console . WriteLine ( LexicographicalMaxString ( str ) ) ; } }