Search⌘ K

DIY: Flood Fill

Understand how to implement the flood fill algorithm to modify images represented as 2D arrays. Explore how to identify connected pixels 4-directionally and apply a new color, preparing you for network and image-related coding interview challenges.

Problem statement

An image is represented by a 2-D array of integers, each integer represents a pixel value of the image between 0 and 65535.

Given a coordinate (sr, sc) representing the flood fill’s starting pixel (row and column) and a pixel value newColor, flood fill ...