We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
No node, no tree, actually it works. I just use the same mechanise that a searchengine should do.
# all letters, a, ab, abc, ..defedge_ngram(contact):return[contact[0:idx]foridxinrange(1,len(contact)+1)]contact_indices={}defadd(contact):fortokeninedge_ngram(contact):contact_indices[token]=contact_indices.get(token,0)+1deffind(name):returncontact_indices.get(name,0)n=int(input().strip())fora0inrange(n):op,contact=input().strip().split(' ')ifop=='add':add(contact)elifop=='find':print(find(contact))
Tries: Contacts
You are viewing a single comment's thread. Return to all comments →
No node, no tree, actually it works. I just use the same mechanise that a searchengine should do.