My first instinct was BFS from each person separately, which technically works but is way slower than it needs to be.
Model the problem as a multi-source BFS from all exits simultaneously, computing the shortest distance from each cell to the nearest exit. Then, the minimum time for all people to escape is the maximum of these distances across all people; if any person cannot reach an exit, return -1.
Pro tip: Clarify upfront that people can share cells and exits without capacity limits, as this simplifies the problem to independent shortest paths. Also, mention that if exits had capacity constraints, the problem would become a flow or matching problem, showing awareness of trade-offs.
Confirm that people can occupy the same cell and that exits have unlimited capacity. Also, verify that blockers are static and that people move simultaneously without interfering.
Treat each cell as a node with edges to its 4-directional neighbors if they are not blockers. Exits are target nodes, and people are sources.
Initialize a queue with all exit cells at distance 0. Perform BFS to compute the shortest distance from every reachable cell to the nearest exit.
For each person, check if their distance is defined (reachable). If any person is unreachable, return -1. Otherwise, the answer is the maximum distance among all people.
Discuss time and space complexity (O(R*C)), and consider edge cases like no people, no exits, or people already at exits.
AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.