Search⌘ K
AI Features

DIY: Flood Fill

Understand how to perform the flood fill algorithm on a 2-D integer array representing an image. Learn to recursively change the color of a starting pixel and all connected pixels sharing its original color to a new color, enhancing your problem-solving skills for image-based coding interview 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 ...