Search⌘ K
AI Features

DIY: Flood Fill

Explore how to implement the flood fill algorithm in Swift by working with 2-D arrays representing images. This lesson helps you understand how to change connected pixel colors starting from a specific coordinate. You'll gain skills useful for tackling coding interview questions focused on network image manipulation and algorithm design.

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