You are given an m x n binary matrix grid. An island is a group of 1's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. The area of an island is the number of cells with a value 1 in the island. Return the maximum area of an island in grid. If there is no island, return 0.
Leetcode 695. Max Area of Island
Given an m×n binary grid, find the maximum area (number of cells) of a 4-directionally connected component of 1s (an island), returning 0 if none exist. This is a standard grid connected-components / flood-fill problem (solvable with DFS/BFS/Union-Find) with m,n ≤ 50.
Onde essa pergunta já apareceu
Use esses exemplos para entender em que contexto ela costuma cair e adaptar sua prática.
Sem observação adicional neste relato público.
Find the max area of an island with a given starting point and obstacles that cannot be passed
Materiais associados
Nenhum anexo público associado a esta pergunta.
Depois de treinar essa pergunta, vale abrir outras do mesmo tipo e da mesma senioridade para comparar padrões de resposta.
Isso ajuda a sair da memorização de uma resposta só e entrar em repertório real de entrevista.
Continue a preparação com o banco completo
No app você encontra perguntas parecidas, compara empresas e aprofunda essa busca com mais filtros.