Here is the code:- https://ide.codingblocks.com/s/432902, The question is 01 Matrix, and the description is below the code, please tell what is the error in the code.
Doubt Implementation of a Problem
for(int i=0; i<4; i++){
int x = currX + dirs[i][0];
int y = currY + dirs[i][1];
if(x >= 0 && x<r_no && y >= 0 && y<col_no && !visited[x][y]){
visited[x][y] = true;
matrix[x][y] = matrix[currX][currY] + 1;
}
}
here u need to push new x and y in the queue.
which u r not doing
pls check ur updated code here->
What does multi source bfs mean, the one you mention? Please explain it.
Thanks for the updated code.
the logic that u r applying is know as multi source bfs.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.