Flood Fill

Easy · Graphs · about 10 minutes

Asked at Microsoft, Amazon, Bloomberg, Meta, Google, Citadel, Jane Street, Susquehanna (SIG).

An image is an m × n grid of integers (pixel colors). Starting from pixel (sr, sc), recolor it and every pixel connected to it 4-directionally through pixels of the same original color to color. Return the modified image.

Related guides