Google

Verified interview challenge

Maintain a mutable priority queue

Keep priority queries correct when existing entries are updated or removed IDs are inserted again.

Unlock with Full Access

The challenge

Process a sequence of priority updates and queries while maintaining one current record per ID. Updates replace earlier priorities, and repeated peeks must leave the queue unchanged. The larger workloads require efficient access to the best current entry, including deterministic handling of tied priorities.

What you'll practise

  • Current-entry correctness

    Ensure old priorities cannot reappear after an update or removal.

  • Efficient ordering

    Handle repeated best-entry queries without scanning the full active set.

Your coding workspacePreview
solution.pyPython 3.13
# Your implementation goes here

# Run examples and inspect results

# Full starter code included
Test cases

Run your code to see results.

Full instructions, starter code and test cases included with Full Access.