You are viewing a single comment's thread. Return to all comments →
My AC python code with your method
loop = int(raw_input()) m = {} def add_word(word): for i in range(1, len(word)+1): if word[:i] in m: m[word[:i]] += 1 else: m[word[:i]] = 1 def find_partial(word): return m.get(word) or 0 for i in range(loop): input = raw_input().split() if input[0] == "add": add_word(input[1]) else: print find_partial(input[1])
Seems like cookies are disabled on this browser, please enable them to open this website
Contacts
You are viewing a single comment's thread. Return to all comments →
My AC python code with your method