1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# nested defaultdict
nested_defaultdict = defaultdict(lambda: defaultdict(int))
# or
dd = defaultdict(dict)
# heapq
class PQ:
def __init__(self, priority):
self.priority = priority
def __lt__(self, other):
return self.priority < other.priority
def __eq__(self, other):
return self.priority == other.priority
|