• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests
November 30, 2023 |440 Views
SDE Sheet - Find whether path exist
  Share  1 Like
Description
Discussion

This video is part of the Graph section under the GFG SDE Sheet.

In this problem, we are given a grid of size n*n filled with 0, 1, 2, 3. Check whether there is a path possible from the source to the destination. You can traverse up, down, right, and left.
The description of cells is as follows:

  • A value of cell 1 means Source.
    A value of cell 2 means Destination.
    A value of cell 3 means Blank cell.
    A value of cell 0 means Wall.

    Note: There are only a single source and a single destination.
     

Example :

Input: grid = {{3,0,3,0,0},{3,0,0,0,3}
,{3,3,3,3,3},{0,2,3,0,0},{3,0,0,1,3}}
Output: 0

Explanation: The grid is-
3 0 3 0 0 
3 0 0 0 3 
3 3 3 3 3 
0 2 3 0 0 
3 0 0 1 3 
There is no path to reach at (3,1) i,e at the destination from (4,3) i,e source.

Try it out before watching the implementation of the problem in the video. We recommend watching the video, even if you can solve the problem. You may discover something new. All the best!!!

Do check out:-
Article: https://www.geeksforgeeks.org/find-whether-path-two-cells-matrix/
Problem: https://www.geeksforgeeks.org/problems/find-whether-path-exist5238/1
SDE Sheet Link: https://www.geeksforgeeks.org/sde-sheet-a-complete-guide-for-sde-preparation/

Read More