As reported: Amazon SDE-1 loop (Bengaluru, February 2025), the DSA round — after Jump Game II and III, a BFS question: Flood Fill.
This is LeetCode 733 — Flood Fill.
An image is an m × n grid of integers (colours). Starting from pixel (sr, sc), change its colour and the colour of every pixel connected to it 4-directionally through pixels of the same original colour to color. Return the modified image.
Example 1
image = [[1,1,1],[1,1,0],[1,0,1]], sr = 1, sc = 1, color = 2
Output: [[2,2,2],[2,2,0],[2,0,1]]
Example 2
image = [[0,0,0],[0,0,0]], sr = 0, sc = 0, color = 0
Output: [[0,0,0],[0,0,0]]
Constraints: 1 ≤ m, n ≤ 50; 0 ≤ image[i][j], color < 2¹⁶; 0 ≤ sr < m; 0 ≤ sc < n.
Code runner format: LeetCode's test-case format — image, sr, sc, color, one per line. Implement floodFill(image, sr, sc, color); the harness prints the image.