Find Path In Matrix | Graphs | C++ Solution
Find Path In Matrix, is a Graphs related problem and in this post we will see how we can solve this challenge in C++
Given a N X N matrix (M) filled with 1 , 0 , 2 , 3 . find whether there is a path possible from source to destination, while traversing through blank cells only. You can traverse up, down, right and left.
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 Blank Wall. Note : there is only single source and single destination.
Examples:
Input : M[3][3] = {{ 0 , 3 , 2 }, { 3 , 3 , 0 }, { 1 , 3 , 0 }}; Output : Yes
Input : M[4][4] = {{ 0 , 3 , 1 , 0 }, { 3 , 0 , 3 , 3 }, { 2 , 3 , 0 , 3 }, { 0 , 3 , 3 , 3 }}; Output : Yes
Please check the main.cpp snippet for the solution.
This solution originally posted at: Github by @susantabiswas
Comments
Leave a comment
You are not LoggedIn but you can comment as an anonymous user which requires manual approval. For better experience please Login.