LeetCode 733
Flood Fill
Concepts:
DFS
BFS
Description: You are given an image represented by an m x n grid of integers image, where image[i][j] represents the pixel value of the image. You are also given three integers sr, sc, and color. Your task is to perform a flood fill on the image starting from the pixel image[sr][sc]. Return the modified image after performing the flood fill.
Optimal Approach
Use basic BFS or DFS to change the color of the current cell and its neighbors with the same color to the new color.
Time: O(nm)
Space: O(nm) for Queue (BFS) or Recursive stack space (DFS)