Search⌘ K
AI Features

DIY: Flood Fill

Explore the flood fill algorithm used to update pixel colors in a 2D image array by targeting connected pixels of the same color. Understand how to solve this common coding interview problem by implementing a function that replaces affected pixels with a new color, enhancing your problem-solving skills for image processing questions.

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 ...