FastPrepMaking a Large Island
Problems/Making a Large Island

Making a Large Island

Meta logoMeta● HardFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The onsite report names the large-island task, and a linked note shows it is the well-known problem with no variant. The grid is square and binary, you may flip one cell, and cells connect in four directions. This follows that definition. Our version is about 95% the same as the reported question.

You are given an n by n binary grid. A value of 1 is land and 0 is water. An island is a group of land cells connected horizontally or vertically; diagonal contact does not connect cells.

You may change at most one water cell from 0 to 1. Return the largest island area that can exist after this change, or after making no change. An island's area is its number of cells.

Function

largestIsland(grid: int[][]) → int

Examples

Example 1

grid = [[1,0],[0,1]]return = 3
grid
01010101

Turning either water cell into land joins the two original islands and the new cell, for area 3.

Example 2

grid = [[1,1],[1,0]]return = 4
grid
01011110

Flip the remaining water cell to create area 4.

Example 3

grid = [[1,1],[1,1]]return = 4
grid
01011111

There is no water to flip; the existing island already has area 4.

Example 4

grid = [[0,0,0],[0,0,0],[0,0,0]]return = 1
grid
012000010002000

A single flipped cell creates an island of area 1.

Constraints

  • 1 <= n <= 500
  • grid.length == n and each row has length n.
  • Each cell is either 0 or 1.

More Meta Onsite Interview questions

  • Deterministic K-Means AssignmentsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Linear Layer Forward and Backward PassesONSITE INTERVIEW · Seen Sep 2026
  • Reservoir Sampling with Recorded DrawsONSITE INTERVIEW · Seen Sep 2026
  • Stochastic Gradient Descent with MomentumONSITE INTERVIEW · Seen Sep 2026
  • Top K Largest Values with a HeapONSITE INTERVIEW · Seen Sep 2026
  • Multi-Head Attention Forward PassPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Mutual-Friend RecommendationsONSITE INTERVIEW · Seen Sep 2026
  • Partition a Card Deck into FifteensONSITE INTERVIEW · Seen Sep 2026
  • Insert into a Sorted Circular ListONSITE INTERVIEW · Seen Aug 2026
  • Maximum Stock Profit with Transaction LimitsONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Largest Island After One Land ConversionGoogle · ONSITE INTERVIEWGoogle interview questions
  • Connected GroupsFivetran · ONSITE INTERVIEWFivetran interview questions
  • Count Islands in a Binary GridApple · PHONE SCREENApple interview questions
  • Connected GroupsVisa · OAVisa interview questions
  • Count Islands in a GridDoorDash · PHONE SCREENDoorDash interview questions
  • Count Islands from Streaming RowsAmazon · ONSITE INTERVIEW
  • Longest Decreasing Matrix Path with Limited RelaxationsDuolingo · ONSITE INTERVIEWDuolingo interview questions
  • Largest Island After One Land ConversionBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Evaluate DivisionPlaud · ONSITE INTERVIEW
  • Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions

Meta interview experiences

  • Meta AI-Native Coding Interview: 3 Experiences
  • Meta Production Engineer Intern Questions: 6 Experiences
All Meta interview questionsSee Meta hiring insights
Saved
class Solution {
    public int largestIsland(int[][] grid) {
        // Write your code here.
    }
}
Checking account…