Driver Code
int main ( ) { string s = " ABCABCABABC " ; string K = " ABC " ; precompute ( s , K ) ; vector < pair < int , int > > Q = { { 1 , 6 } , { 5 , 11 } } ; for ( auto it : Q ) { cout << cnt [ it . second - 1 ] - cnt [ it . first - 1 ] << endl ; } return 0 ; }