# Past Challenges

## leetle

### 12. Count Islands (Square)

63%

Write a function `solve` that counts the number of islands in a square 2D grid. An island is surrounded by water (0s) and is formed by connecting adjacent lands (1s) horizontally or vertically.

**Example:**

`Input: [
[1,1,0],
[0,1,0],
[1,0,1]]`

`Output: 3`

Make sure you `return` your solution, don't print!

```python
def solve(grid):
    pass
```
