Why to learn?
A lot of competitive programming question comes from this topic . To solve dfs we use 2D grid .
Every graph is not tree but every tree is graph
We can up down left and right by 1 unit
DFS on 2D grid
If we go to the right side - j+1
If we go to the left side - j-1
If we go to up - i - 1
If we go to down - i + 1
Changes -
-1,0
1,0
0,1
0,-1
If we go to eight side To go to konakoni
- i - 1 , j+1 i+1,j+1 i-1,j-1 i+1,j-1 DFS on 2D grid Implementation
Top comments (0)