What is "flood fill"?
Flood fill, also called seed fill, is an algorithm that determines the area connected to a given node in a multi-dimensional array.
In other words, it's an algorithm that acts like the paint bucket tool in MS Paint, but for arrays.
How does it work?
Flood fill is (in most implementations) recursive. The process looks like this:
1.) Am I in the bounds of the array? If not, then break.
2.) Am I already filled? If so, then break.
3.) Fill me with the provided value
4.) Attempt to flood fill adjacent cells (Go back to step 1)
5.) Once done, return the new array
Below is an implementation written in C#