We form a substring from that maximum character index till end and check if its greater that maxstring
for ( int i = 0 ; i < index . size ( ) ; i ++ ) { if ( str . substr ( index [ i ] , str . length ( ) ) > maxstring ) { maxstring = str . substr ( index [ i ] , str . length ( ) ) ; } } return maxstring ; }