LeetCode #: 1162
Difficulty: Medium
Topic: Breadth-First Search, Graph.
Assume n
is the total number of cells in the input array.
The solution will go through all the n
cells twice. The first time is to get the initial list of lands. The second time is to perform breadth-first search based on the list of lands to get the maximum distance.