Reachability in a Grid Without Turning

Given an R × C grid:

  • 0 is a walkable cell;
  • X is an obstacle;
  • S is the starting cell;
  • D is the destination cell.

You may take the first step from S in any of the four cardinal...

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: