Given a grid representing a city, it contains the following kinds of entities:
Sources (S): Emit signals.
Blockers (B): Block signal propagation.
Empty cells (.): Signals can pass through freely.
Targets (T): Need to receive a signal.
Signals start simultaneously from all sources. Each unit of time, they move one cell in each of four directions: up, down, left, and right. Signals cannot pass through blockers. Find the minimum time needed for every target to receive a signal. If any target cannot be reached, return -1.
Follow-up:
- If you can destroy at most one blocker, which blocker should you destroy to minimize the time needed for all targets to receive a signal?
Discussion
Loading comments…