You are viewing a single comment's thread. Return to all comments →
Python 3 - bit of a hack but it works.
import bisect n = int(input().strip()) contacts = [] for a0 in range(n): op, contact = input().strip().split(' ') if op == 'add': bisect.insort_left(contacts, contact) if op == 'find': left = bisect.bisect_left(contacts, contact) right = bisect.bisect_left(contacts, contact + 'zzzzzzz', left) print(right - left)
Tries: Contacts
You are viewing a single comment's thread. Return to all comments →
Python 3 - bit of a hack but it works.