FastPrepNumber of Islands
Problems/Number of Islands

Number of Islands

Citadel logoCitadel● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Citadel new grad phone screen. The main coding question was a well-known problem. The report names the problem without its full wording. Here, the grid uses integer 0 and 1 cells and four-direction adjacency.

Our version is about 98% the same as the reported question.

A binary grid contains land (1) and water (0). An island is a maximal group of land cells connected horizontally or vertically. Diagonal contact does not connect cells.

Return the number of islands.

Function

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

Examples

Example 1

grid = [[1,1,0,0,1,1],[1,0,0,0,1,0],[0,0,0,0,0,0]]return = 2
grid
012345011001111000102000000

There are two separate L-shaped islands.

Example 2

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

Diagonal cells are separate, giving five islands.

Constraints

  • 1 <= grid.length <= 200
  • 1 <= grid[0].length <= 200
  • All rows have the same length.
  • Each grid entry is 0 or 1.

More Citadel Phone Screen questions

  • Portfolio Tickers with Constant-Time Random PickPHONE SCREEN · Seen Nov 2026
  • Square Root FunctionPHONE SCREEN · Seen Oct 2026
  • Reachable Transfer PositionsPHONE SCREEN · Seen Oct 2026
  • Spreadsheet Formula DependenciesPHONE SCREEN · Seen Oct 2026
  • Merge Price-Delta FeedsPHONE SCREEN · Seen Sep 2026
  • Reconcile Unmatched Trades with Timestamp TolerancePHONE SCREEN · Seen Sep 2026
  • Top Ten Trades by Notional ValuePHONE SCREEN · Seen Sep 2026
  • Exchange BBO and Market-Wide NBBOPHONE SCREEN · Seen Sep 2026
  • Maximize Workday EarningsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Minimum Changes for Palindromic BlocksOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026

Similar questions at other companies

  • Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Word Chain Jumps in a GridGoogle · PHONE SCREENGoogle interview questions
  • Minimize CommuteDatabricks · OA · PHONE SCREENDatabricks interview questions
  • Count Connected IslandsUber · PHONE SCREENUber interview questions
  • Number of IslandsSpaceX · PHONE SCREENSpaceX interview questions
  • Count Islands in a Binary GridApple · PHONE SCREENApple interview questions
  • Find and Reconstruct a Binary-Matrix PathMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
  • Pacific Atlantic Water FlowAnduril · PHONE SCREENAnduril interview questions
  • Xiangqi Horse ReachabilityeBay · PHONE SCREENeBay interview questions
  • Grid Pathfinding with Obstacles (DFS)Roblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions

Interview reports that mention this question

  • Citadel SWE Intern First-Round Questions: 20 Experiences

Citadel interview experiences

  • Citadel Securities Quant Researcher Intern Loop: 1 Experience
  • Citadel Securities Research Engineer Interview: 1 Experience
  • Citadel Securities SWE Intern First Round: 2 Experiences
  • Citadel Securities Experienced SWE Interviews: 1 Experience
  • Citadel SWE Intern Later Rounds and Superday: 13 Experiences
All Citadel interview questionsSee Citadel hiring insights
Saved
class Solution {
    public int numIslands(int[][] grid) {
        // write your code here
    }
}
Checking account…