• Tutorials
  • DSA
  • Data Science
  • Web Tech
  • Courses
August 03, 2023 |1.9K Views

PROBLEM OF THE DAY: 02/08/2023 | Shortest Source to Destination Path

Description
Discussion

In this video, we are given a 2D binary matrix A(0-based index) of dimensions NxM. We have to find the minimum number of steps required to reach from (0,0) to (X, Y).
Note: You can only move left, right, up, and down, and only through cells that contain 1. 

Example :

Input:
N=3, M=4
A=[[1,0,0,0], 
      [1,1,0,1],
      [0,1,1,1]]
X=2, Y=3 

Output:
5

Explanation:
The shortest path is as follows:
(0,0)->(1,0)->(1,1)->(2,1)->(2,2)->(2,3).

Give the problem a try before going through the video. All the best!!!

Problem Link: https://practice.geeksforgeeks.org/problems/shortest-source-to-destination-path3544/1