Use set with `in` operator
Codeforces Rd #368 (Div. 2) Problem B
In this problem, one of the task is to identify whether the city has a storage.
One important thing to get rid of time exceed error is to use set, instead of list, for has_storage.
According to Python Wiki, the average case for
is O(n),
is O(1).
This stackoverflow thread also illustrated the time difference.
Tags:
python,