Driver code
public static void main ( String [ ] args ) { String s = " abaaab " ; boolean [ ] [ ] dp = new boolean [ N ] [ N ] ; pre_process ( dp , s . toCharArray ( ) ) ; int queries [ ] [ ] = { { 0 , 1 } , { 1 , 5 } } ; int q = queries . length ; for ( int i = 0 ; i < q ; i ++ ) { answerQuery ( queries [ i ] [ 0 ] , queries [ i ] [ 1 ] , dp ) ; } } }