🚀 Google SDE-3 Interview Question | Graphs + BFS | CTC ₹65–85 LPA
Video Solution for the problem - (found it recently)
You are given a city represented as an N × M grid. Each cell can be one of the following:
'.' → an empty road (walkable)
'#' → a blocked building (not walkable)
'S' → starting position of the rescue team
'E' → the exit point that must be reached
'F' → a fire source
🔥 Fire Spread Rules:
Fire spreads to all 4-neighbors (up, down, left, right) every minute.
🧑🚒 Rescue Team Rules:
The rescue team can also move to 4-neighbors every minute (only into '.' or 'E').
The team cannot enter or stay in a cell once fire has reached it.
🎯 Goal:
Determine whether the rescue team can reach E before the fire catches up.
If yes, print the minimum time needed. Otherwise, print -1.
✅ Input Format
T → number of test cases
N M → grid dimensions
Grid → N lines of M characters
✅ Output Format
For each test case, print the minimum time to reach exit, or -1 if impossible.
🔁 Follow-up
Multiple cells may initially contain fire 'F'.
Anyone has solution for it ? - Thankyou :)

