Meta Coding Interview: Biggest Island on the Map

Based on questions reported for Meta interviews

The interviewer opens

Hi, and thanks for joining. Welcome to your interview for the software engineer role at Meta. We'll work through one coding problem together, and I'd like you to think out loud as you go. If you need to step out or take a break, you can pause the interview any time with the Pause button at the top right.

The problem is about finding the biggest island on a map of land and water, and it's in the Problem tab on your right. Please read it through, take your time, and ask me any questions before you start.

The problem

A map of land and water is given as a grid; find its biggest island.

  • grid: an m x n list of rows, each cell 1 (land) or 0 (water).

An island is a group of land cells connected horizontally or vertically (not diagonally); its size is its number of cells. Return the size of the largest island, or 0 if the grid has no land.

Example: grid = [[1,1,0,0],[1,0,0,1],[0,0,1,1],[0,1,1,0]] → 5

1 ≤ m, n ≤ 500.