leetcode1034】的更多相关文章

Given a 2-dimensional grid of integers, each value in the grid represents the color of the grid square at that location. Two squares belong to the same connected component if and only if they have the same color and are next to each other in any of t…
class Solution: def __init__(self): self.V = list() def bfs(self,grid,color,rows,coloums,r,c,ocolor): cur = [r,c] if cur[0]-1 >=0 and self.V[cur[0]-1][cur[1]]==0 and grid[cur[0]-1][cur[1]]==ocolor: grid[cur[0]-1][cur[1]] = color self.V[cur[0]-1][cur[…