https://leetcode.com/problems/max-area-of-island/

Golang:

func maxAreaOfIsland(grid [][]int) int {
    height := len(grid)
    if height == 0 {
        return 0
    }
    width := len(grid[0])
    
    visited := make([][]bool, height)
    for i := range visited {
        visited[i] = make([]bool, width)
    }
    
    maxArea := 0
    
    for i := 0; i < height; i++ {
        for j := 0; j < width; j++ {
            curtArea := explore(grid, visited, i, j) 
            if curtArea > maxArea {
                maxArea = curtArea
            }
        }
    }
    
    return maxArea
}


func explore(grid [][]int, visited [][]bool, i,j int) int {
    height := len(grid)
    width := len(grid[0])
    if visited[i][j] || grid[i][j] == 0{
        return 0
    }
    area := 1
    visited[i][j] = true
    if i - 1 >= 0 {
        area += explore(grid, visited, i - 1, j)
    }
    if i + 1 < height {
        area += explore(grid, visited, i + 1, j)
    }
    if j - 1 >= 0 {
        area += explore(grid, visited, i, j - 1)
    }
    if j + 1 < width {
        area += explore(grid, visited, i, j + 1)
    }
    return area
}