Company: Google
Difficulty: medium
Signal Propagation in a Grid You are given a rows x cols grid representing a city. Each cell contains exactly one of the following characters: S - source : emits a signal. B - blocker : blocks signal propagation. . - empty cell : the signal can pass through. T - target : must receive the signal. The signal spreads from all sources simultaneously . In one unit of time, the signal moves from a cell it already occupies to any of the four orthogonally adjacent cells - up, down, left or right. It can never enter a blocker cell and never leave the grid. Source, empty and target cells are all transparent: once the signal reaches such a cell it keeps spreading through it. Every source is emitting at time 0 , so a target receives the signal at the moment given by its shortest blocker-free path to the nearest source, measured in steps. Return the minimum time required for every target to have received the signal , that is, the largest of those per-target times. If even one target cannot be reach