Your question is Flood Fill App Implementation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
Pinterest's image editor represents a canvas as a rectangular grid of color values. When a user selects a pixel, implement a flood fill that recolors the entire four-directionally connected region containing that pixel.
A cell belongs to the region if it has the same original color as the starting cell. Return the modified canvas. Diagonal cells are not connected.
Implement fill_canvas(canvas, sr, sc, new_color).
canvas is a non-empty list of non-empty lists of integers, where each integer represents a color.sr and sc are valid zero-based row and column indices.new_color is an integer.canvas.Use an iterative traversal so the algorithm does not depend on Python's recursion limit.
def fill_canvas(canvas, sr, sc, new_color):