Skip to content

Instantly share code, notes, and snippets.

@wanderindev
Created June 19, 2022 03:02
Show Gist options
  • Select an option

  • Save wanderindev/79a068049fcd2a8007e77c3b2d012da2 to your computer and use it in GitHub Desktop.

Select an option

Save wanderindev/79a068049fcd2a8007e77c3b2d012da2 to your computer and use it in GitHub Desktop.
def insert(self, task: str, priority: int) -> None:
"""Add an item to the priority queue"""
heapq.heappush(self.pqueue, (priority, self.insertion_count, task))
self.insertion_count += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment