Module 6 · Stacks and Queues · Common Mistakes

Stacks and Queues: common mistakes

Stacks and queues fail at their edges: when they're empty, when they wrap, when an old value should leave. Here are three slips: popping an empty stack in Backspace String Compare, a circular queue's rear without % n, and Sliding Window Maximum keeping a maximum that has left the window.

Pick a mistake and press play: Wrong runs the code with the mistake until it breaks, and the code marks the wrong line in red. Fixed runs the corrected code on the same input, with the corrected line in green.

Mistake
Code