Lexicographical Maximum substring of string | CPP program to find the lexicographically maximum substring . ; loop to find the max leicographic substring in the substring array ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; string LexicographicalMaxString ( string str ) { string mx = " " ; for ( int i = 0 ; i < str . length ( ) ; ++ i ) mx = max ( mx , str . substr ( i ) ) ; return mx ; } int main ( ) { string str = " ababaa " ; cout << LexicographicalMaxString ( str ) ; return 0 ; }