Flood Fill

Asked at Apple · Coding & Leetcode-style Questions · Difficulty: Easy · Last asked Apr 20, 2026

You are given an `m x n` integer grid `image` where `image[r][c]` is the pixel color at that position, and three integers `sr`, `sc`, and `color`. Starting from pixel `(sr, sc)`, replace the color of all pixels connected 4-directionally (up, down, left, right) that share the original color with `color`.

Loading the problem…