Returns count of occurrences of s in Trie
int search ( Trie * root , string s ) { int n = s . size ( ) ; for ( int i = 0 ; i < n ; i ++ ) { int index = s [ i ] - ' a ' ; if ( ! root -> node [ index ] ) return 0 ; root = root -> node [ index ] ; } return root -> cnt ; } void answerQueries ( string arr [ ] , int n , string q [ ] , int m ) { Trie * root = new Trie ( ) ;