Dodomeki
Sign in

32. Largest Island Area

Easy

In a matrix of integers, 1 represents land and 0 represents water. Return the number of cells in the largest island, connected only by sides. If there is no land, return 0.

Example 1
Input: grade = [[1,1,0,0],[1,0,0,1],[0,0,1,1]]
Output: 3
Example 2
Input: grade = [[1,1,1,1]]
Output: 4
Constraints
  • 0 <= linhas, colunas <= 300
  • Each cell is 0 or 1.
GraphsDFSMatrix
Caso 1
grade =
[[1,1,0,0],[1,0,0,1],[0,0,1,1]]
Expected =
3
Caso 2
grade =
[[1,1,1,1]]
Expected =
4

Run checks these 2 cases. Submit runs all 6, including hidden ones.