Complexity issue

what is the time and space complexity of flood fill algorithm?

The time complexity would be O(4*mn)=(mn) because each cell of matrix is processed at most 4 times. For Example, a particular cell can be called by its top, down, left or right cell.
Space Complexity will be O(n * m) , because of visited array.

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.