A robot moves on a grid: 'S' start, 'T' target, '#' shelf (blocked), '.' open. Each move goes one cell up/down/left/right. Return the minimum moves from S to T, or -1.
Signature
shortestRoute(grid: string[]) → intExample 1
grid = ["S.#.","..#.","...T"]
output = 5
down, down, right ×3 = 5
Example 2
grid = ["S#","#T"]
output = -1
blocked → -1
Constraints
1 ≤ rows, cols ≤ 500exactly one S and one T
⌘/Ctrl + Enter runs examples
Run checks the examples. Submit runs every hidden test (17, including large inputs that catch slow solutions).