Front Or Back
A robot drives on a grid. Continuing straight costs 0, turning 90 degrees costs 1. Your state is (cell, heading), so every edge weighs 0 or 1. You solve it with a binary heap in .
A teammate swaps the heap for a deque: on a 0-weight edge they push_front, on a 1-weight edge they push_back, and they pop from the front. Same answers, and measurably faster on the same input.
What makes the deque version correct?
Sign in to answer questions and track your progress
Sign In