Grid Signals

Asked at GoogleOnsite

Reported by the problem's creator, not verified

A grid is a list of strings of equal length. S is a signal source, T is a target that must receive a signal, B is a blocker, and . is an empty cell. All sources start emitting at time 0, and each time unit a signal moves from a cell to each of its four neighbours. Signals pass through empty cells, sources and targets, and never enter a blocker. A target receives the signal at a time equal to its distance to the nearest source.

Examples

  1. Example 1

    Input: grid = ["S..T","...."]

    Output: [3]

    Explanation: The signal needs 3 steps to travel from the S cell to the target across the top row, so the answer is [3].

Import your own questions
Paste a question you were asked and get a full problem: statement, tests and a checked solution.
Import a question

Code

Loading editor…

Ln 1, Col 1

Start an attempt to use Coach.