2
* @param {number[][]} image5
* @param {number} color8
var floodFill = function (image, sr, sc, color) {9
const pixelsToCheck = [[sr, sc]];10
const startingPixelColor = image[sr][sc];17
const seenPixels = new Set();19
if (startingPixelColor === undefined || startingPixelColor === color)22
for (const pixel of pixelsToCheck) {23
const currentPixelColor = image[pixel[0]]?.[pixel[1]];26
currentPixelColor === undefined ||27
startingPixelColor !== currentPixelColor31
image[pixel[0]][pixel[1]] = color;33
for (const direction of directions) {34
const newPixel = [pixel[0] + direction[0], pixel[1] + direction[1]];35
const pixelString = newPixel.join();37
if (seenPixels.has(pixelString)) continue;39
pixelsToCheck.push(newPixel);40
seenPixels.add(pixelString);