Sir didn’t checked for cycles in DFS while solving flood fill problem. isn’t we have to check for cycles while traversing. So here we should be using visited[][] to keep track of visited indices. Then while traversing it will not end up in cycles? Correct me if i m wrong ?
Flood fill DFS approach
Yes, you need to maintain a visited array but the question which Bhaiya discussed does not need a visited array because if a dot is colored with some color then next time we won’t find dot at its place.
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.