题目
分析
这道题非常简单,其实就是让你遍历当前图形的所有节点,并且修改颜色为新颜色就好了。通过dfs和bfs都能实现。代码如下:
class Solution {
public int[][] floodFill(int[][] image, int sr, int sc, int newColor) {
if(image[sr][sc]==newColor) return image;
coloring(image,sr,sc,image[sr][sc],newColor);
return image;
}
public void coloring(int[][] image,int x,int y,int oldColor,