Some common Python library.
Collections
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| import queue pq = queue.PriorityQueue() pq.put(2) pq.put(4) num = pq.get()
import heapq nums = [] heapq.heappush(nums, 2) heapq.heappush(nums, 4) num = heapq.heappop(nums)
dic = {} dic = dict() dic = collections.defaultdict() dic = collections.defaultdict(list) dic = colelctions.Counter([1, 1, 2, 3, 4])
se = set()
a = [] a.append(0) a.append(1) a.pop(0) a.pop()
|