Back to problems

Maximum Island Area

Algorithm · Amazon · Easy

You are handed a two-dimensional grid made up solely of the characters 0 and 1. A 1 marks a land cell and a 0 marks a water cell. Two land cells belong to the same island when they touch each other directly in the up, down, left or right direction; diagonal contact does not count. The area of an island is the total number of land cells it contains. Find the largest island area in the grid and return it. If the grid has no land at all, return 0. The grid has m rows and n…

Loading the rest of the question…