Search⌘ K
AI Features

DIY: Flood Fill

Explore how to implement the flood fill algorithm in Rust to change connected pixel regions in a 2-D image array. Understand how to identify connected pixels from a starting coordinate and recolor them efficiently. Practice applying this technique to solve common interview problems involving matrix traversal and recursion.

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 new_color, flood fill ...