Back to problems

Number of Islands with Max-Area and Streaming-Rows Follow-Ups

Algorithm · Amazon · Medium

You are given a 2D matrix that contains only 0 and 1. A group of 1 cells that touch each other horizontally or vertically (up, down, left or right) forms an island. Return how many islands the matrix contains. No examples or numeric constraints were provided for this problem. Follow-ups Follow-up 1: In addition to the number of islands, return the area of the largest island. Follow-up 2: Suppose the matrix arrives as a stream, one row at a time. How would you keep the island…

Loading the rest of the question…