Add count of substring equal to n - alphaIndex [ i ] [ j ]
rank = rank + ( n - alphaIndex [ i ] [ j ] ) NEW_LINE strr = [ ] NEW_LINE for i in range ( len ( alphaIndex [ ord ( s [ 0 ] ) - ord ( ' a ' ) ] ) ) : NEW_LINE