Sewer Connectivity / Reachability in a Grid (DFS)

You are given a 2D grid grid representing a sewer/pipeline system:

  • . passable cell
  • # wall/blocked cell
  • S start
  • T target

You may move in 4 directions (up/down/left/right), no diagon...

Example

Unlock to view complete problem details

and practice with sample input/output

Was this article helpful?

View Test Cases & Run Code requires membership

Standard Input
Execution Result: