FastPrepMax Area of Island
Problems/Max Area of Island

Max Area of Island

Goldman Sachs logoGoldman Sachs● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Goldman Sachs superday report describes the classic task of the maximum area of 1s in a grid, with a detailed talk about DFS versus BFS. It does not give the function signature, which cells count as neighbors, examples, or constraints. This version uses four directions. Our version is about 95% the same as the reported question.

Given a rectangular binary matrix grid, return the maximum area of an island. An island is a maximal group of cells containing 1 connected horizontally or vertically. Its area is its number of cells.

Return 0 when the matrix contains no land.

Function

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

Examples

Example 1

grid = [[0,0,1,0],[1,1,1,0],[0,1,0,1]]return = 5
grid
0123000101111020101

The center island contains five orthogonally connected land cells. The bottom-right cell is a separate island of area 1.

Example 2

grid = [[0,0],[0,0]]return = 0
grid
01000100

There are no land cells.

Constraints

  • 1 <= grid.length, grid[i].length <= 300.
  • Every row has the same length.
  • grid[i][j] is either 0 or 1.

More Goldman Sachs Onsite Interview questions

  • Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
  • Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
  • First Non-Repeating CharacterPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Root of the Largest TreePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Dungeon HealthONSITE INTERVIEW · Seen Sep 2026
  • Insert, Delete, And Get Random In Constant TimeONSITE INTERVIEW · Seen Sep 2026
  • Least Recently Used CacheONSITE INTERVIEW · Seen Sep 2026
  • Staircase Search In A Sorted MatrixONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Number of Islands with Diagonal ConnectivityGoogle · ONSITE INTERVIEWGoogle interview questions
  • Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
  • Max Area of IslandRoku · ONSITE INTERVIEWRoku interview questions
  • Max Area of IslandBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Maximum Area of IslandSambaNova Systems · ONSITE INTERVIEWSambaNova Systems interview questions
  • Count Islands in a Binary GridApple · PHONE SCREENApple interview questions
  • Pacific Atlantic Water FlowAnduril · PHONE SCREENAnduril interview questions
  • Maximum Damage PatchGecko Robotics · OA · PHONE SCREEN
  • Maximum Area of IslandSkydio · PHONE SCREENSkydio interview questions
  • Number of IslandsFleetx · ONSITE INTERVIEW
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public int maxIslandArea(int[][] grid) {
        // Write your code here.
    }
}
Checking account…