FastPrepCount Land Islands
Problems/Count Land Islands

Count Land Islands

Roblox logoRoblox● MediumFULLTIMEONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in a Roblox onsite interview. The candidate reports a graph walk similar to an island problem, without the exact prompt. We chose to count groups of land, four-way connection of land, the interface, and the limits. Our version is about 60% the same as the reported question.

For this exercise, assume grid is a rectangular map: 1 is land and 0 is water. An island contains all land cells you can reach from one another by moving through land up, down, left, or right. Diagonals do not connect islands.

Return the number of islands. Do not change the input. A grid with no cells has zero islands.

Function

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

Examples

Example 1

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

The upper-left group, lower-left cell and right-hand group are three islands.

Example 2

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

The two land cells touch only diagonally.

Example 3

grid = []return = 0

The map has no rows.

Constraints

  • 0 <= grid.length <= 60.
  • All rows have the same length c, with 0 <= c <= 60.
  • Every cell is 0 or 1.

More Roblox Onsite Interview questions

  • Most Frequent Call Path From Function Trace LogsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Search Autocomplete SystemPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Candy Crush Grid Matching and GravityPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Topological Sort with Secondary OrderingPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Most Frequent Call Stack Per ThreadPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Count and Score Distinct Hat AssignmentsONSITE INTERVIEW · Seen Sep 2026
  • Rate Limiter Sliding Window With Per-Entity LimitsPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Most Frequent Call Path in Interleaved LogsONSITE INTERVIEW · Seen Aug 2026
  • Grid Pathfinding with Obstacles (DFS)PHONE SCREEN · ONSITE INTERVIEW · Seen Jun 2026
  • Maximize Distance to Closest Person — Return the SeatONSITE INTERVIEW · Seen Jun 2026

Similar questions at other companies

  • Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Explore an Unknown Grid and Find a PathLinkedIn · ONSITE INTERVIEWLinkedIn interview questions
  • Nearest Charging Station on a GridSpotify · ONSITE INTERVIEW
  • Number of Islands with Diagonal ConnectivityGoogle · ONSITE INTERVIEWGoogle interview questions
  • Island Count and Maximum AreaOracle · ONSITE INTERVIEWOracle interview questions
  • Shortest Increasing Path to a TargetUber · ONSITE INTERVIEWUber interview questions
  • Mouse and Cheese ReachabilityMeta · ONSITE INTERVIEWMeta interview questions
  • Number of IslandsTripjack · ONSITE INTERVIEWTripjack interview questions
  • Number of IslandsTekion · ONSITE INTERVIEWTekion interview questions
  • Number of IslandsGoldman Sachs · OA · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions

Interview reports that mention this question

  • Roblox New Grad Coding Rounds: 23 Experiences (Part 2 of 7)

Roblox interview experiences

  • Roblox OA: What It Tests (2026)
  • Roblox New Grad Early OA Tasks: 10 Experiences (Part 7 of 7)
  • Roblox New Grad Engineer Rounds: 13 Experiences (Part 6 of 7)
  • Roblox New Grad HackerRank OA: 18 Experiences (Part 5 of 7)
  • Roblox New Grad CodeSignal Finals: 23 Experiences (Part 4 of 7)
All Roblox interview questionsSee Roblox hiring insights
Saved
class Solution {
    public int countIslands(int[][] grid) {
        // write your code here
    }

}
Checking account…