Calculate length of string
int n = s . length ( ) ; vector < vector < int > > pref ( 26 , vector < int > ( n , 0 ) ) ; vector < vector < int > > pos ( 26 ) ; pref [ s [ 0 ] - ' a ' ] [ 0 ] ++ ; pos [ s [ 0 ] - ' a ' ] . push_back ( 0 ) ;