LeetCode 733 Flood Fill - Solution

The pattern

DFS (or BFS) from the starting pixel. If the current pixel has the original color, change it to the new color and recurse to neighbors.

Edge case: if the starting color equals the new color, return immediately (no work needed).

This is the simplest flood fill: visit all reachable cells of the same color and recolor them.