FastPrepNumber of Islands II
Problems/Number of Islands II

Number of Islands II

Citadel logoCitadel● MediumNEW GRADPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Citadel new grad phone screen. Near the end, the candidate described the solution to a well-known problem. Only an oral solution was reported. This version uses a finite list of land additions and four-direction adjacency. Adding land that is already there leaves the grid unchanged.

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

Start with an m-by-n grid of water. Each position changes that cell to land. Adding land to a cell that is already land does nothing.

After every addition, return the number of islands. Land is connected through four sides, not diagonals.

Function

numIslands2(m: int, n: int, positions: int[][]) → int[]

Examples

Example 1

m = 3n = 3positions = [[0,0],[0,1],[1,2],[2,1],[1,1]]return = [1,1,2,3,1]

The last addition joins the top-left island and both isolated cells, leaving one island.

Example 2

m = 1n = 2positions = [[0,0],[0,0],[0,1]]return = [1,1,1]

The repeated first cell changes nothing. The final cell joins the existing island.

Constraints

  • 1 <= m, n <= 100
  • 1 <= positions.length <= 10000
  • Each position is [row, column] with 0 <= row < m and 0 <= column < n.

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

  • Capture Surrounded Regions with Union-FindApple · PHONE SCREENApple interview questions
  • Minimum Rooks in a Peaceful State (SDE 2, Phone Interview)Amazon · PHONE SCREEN
  • Count the IslandsAdobe · PHONE SCREENAdobe interview questions
  • Count Islands in a GridDoorDash · PHONE SCREENDoorDash interview questions
  • Dynamic Island CountsUber · PHONE SCREENUber interview questions
  • Number of Islands IISpaceX · PHONE SCREENSpaceX interview questions
  • Connected GroupsFivetran · ONSITE INTERVIEWFivetran interview questions
  • Number of IslandsExpedia · ONSITE INTERVIEWExpedia interview questions
  • Rectangular K-in-a-RowDatabricks · ONSITE INTERVIEWDatabricks interview questions
  • Connected GroupsVisa · OAVisa 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[] numIslands2(int m, int n, int[][] positions) {
        // write your code here
    }
}
Checking account…