You are viewing a single comment's thread. Return to all comments →
You can simplify it even more using Counter.
from collections import * cter = Counter() for i in xrange(int(raw_input().strip())): cmd, word = raw_input().strip().split(' ') if cmd == 'add': for i in xrange(1, len(word) + 1): cter.update([word[0:i]]) else: print cter[word]
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 →
You can simplify it even more using Counter.