Driver code
static void Main ( ) { string s = " ABCABCABABC " ; string K = " ABC " ; precompute ( s , K ) ; int [ , ] Q = { { 1 , 6 } , { 5 , 11 } } ; for ( int it = 0 ; it < Q . GetLength ( 0 ) ; it ++ ) { Console . WriteLine ( cnt [ Q [ it , 1 ] - 1 ] - cnt [ Q [ it , 0 ] - 1 ] ) ; } } }