What do you want to save?
Add Code snippet
New code examples
-
Python 2021-11-06 19:01:23
python heapq
>>> import heapq >>> heap = [] >>> heapq.heappush(heap, (5, 'write code')) >>> heapq.heappush(heap, (7, 'release product')) >>> heapq.heappush(heap, (1, 'write spec')) >>> heapq.heappush(heap, (3, 'cre... Add solution -
Python 2021-10-10 08:22:04
python version of settimout
from datetime import datetime, timedelta import heapq # just holds a function, its arguments, and when we want it to execute. class TimeoutFunction: def __init__(self, function, timeout, *args): self.function = function self.args = ar... Add solution -
Python 2021-09-23 16:25:05
dijkstra implementation with the help of priority queue in python
import heapq def calculate_distances(graph, starting_vertex): distances = {vertex: float('infinity') for vertex in graph} distances[starting_vertex] = 0 pq = [(0, starting_vertex)] while len(pq) > 0: current_distance, current... Add solution
Best helpers
Ranking is empty