https://leetcode.com/problems/number-of-islands/



Time Limit Exceeded



```python
class Solution:
    def numIslands(self, grid: List[List[str]]) -> int:
        #I did a check on the discuss. The matrix is already the smallest form of data that we could use to represent the lsland. 
        #There has no way to do it futher.
        #That's why here we don't need to create any new data structure.
        #We do the counting, that's all
        
        #Let me try it again
        #7:58
        self.locations_used = []
        
        def get_all_1_around(y, x):
            if (y >= 0 and y < len(grid) and x >= 0 and x < len(grid[0])):
                if (grid[y][x] == "1"):
                    if (y,x) not in self.locations_used:
                        self.locations_used.append((y,x))
                        get_all_1_around(y, x+1)
                        get_all_1_around(y, x-1)
                        get_all_1_around(y+1, x)
                        get_all_1_around(y-1, x)
            else:
                return
        
        counting = 0
        while True:
            cant_found_new_element = True
            for y, row in enumerate(grid):
                for x, value in enumerate(row):
                    if (value == "1"):
                        if (y,x) not in self.locations_used:
                            get_all_1_around(y,x)
                            counting += 1
                            cant_found_new_element = False
            if cant_found_new_element == True:
                break
        return counting
        #8:10
```



> Maybe for unintelligent people, the only redemption is to do one thing, using their whole life. 

> It is fine to be a tool if you meet the right boss who has mercy.
