150: Maximum area of island

Given a 2D matrix, the matrix contains 0 (water) and 1(land), return maximum area of the island

Note: An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. All four edges of the matrix are all surrounded by water

 

Example 1

Input:    0 0 0 0 0
          0 1 1 0 0
          0 1 1 0 1 
          0 0 0 1 1 

Output: 4

Example 2

Input:    1 0 0 0 0
          0 1 0 0 0
          0 0 1 0 0
          0 0 0 1 0

Output: 1
Difficulty:Medium
Topic:Graph
Problem #:150