A Priority Queue with Priority Updates

medium
Unit 22 · Bisect0/0 to milestone

heapq can't change an item's priority. The standard trick is lazy deletion: push a new entry and mark the old one as removed.

Pro problem

Unlock this and every premium problem across all tracks — plus hidden-test grading, advanced AI engineering modules and new content every week.

Start 7-day free trial
solution.py · Python 3.13
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
A Priority Queue with Priority Updates · TechGradify