Returns count of occurrences of s in Trie
def search ( root , s ) : NEW_LINE INDENT n = len ( s ) NEW_LINE for i in range ( n ) : NEW_LINE INDENT index = ord ( s [ i ] ) - ord ( ' a ' ) NEW_LINE if ( not root . node [ index ] ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT root = root . node [ index ] NEW_LINE DEDENT return root . cnt NEW_LINE DEDENT def answerQueries ( arr , n , q , m ) : NEW_LINE INDENT root = Trie ( ) NEW_LINE DEDENT