Search⌘ K
AI Features

DIY: Flood Fill

Explore how to implement the flood fill algorithm on a 2D image array using Kotlin. This lesson helps you understand how to identify and update connected pixels by color, teaching you an essential technique for image processing and coding interview problem solving.

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