Algorithm · Apple · Easy
You receive an m x n integer matrix named image, where image[r][c] denotes the color of the pixel at row r and column c. Given integers sr, sc, and color, begin at (sr, sc) and change every pixel in its 4-connected region—using only up, down, left, and right moves—that initially matches the starting pixel's color to color. Return the updated image. Examples Example 1: Input: image = [[3,3,3],[3,3,1],[3,1,3]], sr = 0, sc = 0, color = 7 Output: [[7,7,7],[7,7,1],[7,1,3]]…
Checking your access…