Add count of substring equal to n - alphaIndex [ i ] [ j ]
rank = rank + ( n - alphaIndex [ i ] [ j ] ) ; } } } vector < string > str ; for ( int i = 0 ; i < alphaIndex [ s [ 0 ] - ' a ' ] . size ( ) ; i ++ ) {