Help in question Mayhem Again of DSA learning series(Contest 8)

https://www.codechef.com/LRNDSA08/problems/MARLA
How to solve this question I am not getting idea

https://www.codechef.com/viewsolution/33998215
use dfs for every value in matrix and take vis matrix to mark visited box

1 Like

Thanks

1 Like