# Flood Fill (Leetcode 733)

Problem Link: <https://leetcode.com/problems/flood-fill/>

```python
class Solution:
    def floodFill(self, image: List[List[int]], sr: int, sc: int, color: int) -> List[List[int]]:
        
        def recursion(image,i,j,oldColor,newColor,m,n):
            if(i<0 or j<0 or i>=m or j>=n or image[i][j]!=oldColor):
                return
            
            image[i][j]=newColor
            recursion(image,i+1,j,oldColor,newColor,m,n)
            recursion(image,i,j+1,oldColor,newColor,m,n)
            recursion(image,i-1,j,oldColor,newColor,m,n)
            recursion(image,i,j-1,oldColor,newColor,m,n)
        
         
        oldColor=image[sr][sc]
        newColor=color
        if(oldColor==newColor):
            # No need of modifications in this case
            # because it is already flood-filled
            return image
        m=len(image)
        n=len(image[0])
        recursion(image,sr,sc,image[sr][sc],newColor,m,n)
        return image
```
