Here is a dungeon with two gates and some walls. You need the shortest distance from every empty room to the nearest gate. The obvious approach: run BFS from each gate separately, take the minimum.
My first instinct was to loop over the gates and run BFS from each one. It passed all test cases. Then I saw the time limit on larger inputs and realized I was doing the same work multiple times over. The fix was embarrassingly simple.
After gate A's BFS fills the grid, gate B's BFS will overwrite some cells with smaller distances. Will gate B's BFS visit cells that gate A's BFS ALREADY visited?