FastPrepCount Isolated Islands
Problems/Count Isolated Islands

Count Isolated Islands

Microsoft logoMicrosoft● MediumFULLTIMEPHONE SCREEN

Updated Oct 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A Microsoft Applied Scientist internship phone screen reports a simple isolated-islands coding problem. Counting land components that avoid the boundary, binary cell values, four-direction adjacency, interface, and bounds are conventional enrichment selected from the abbreviated source.

Given a rectangular binary grid represented by equal-length strings, count the islands of land cells marked '1' that do not touch the grid boundary.

Land cells connect horizontally or vertically. An isolated island is a maximal connected land component with no boundary cell.

Function

countIsolatedIslands(grid: String[]) → int

Examples

Example 1

grid = ["00000","01100","01010","00010","00000"]return = 2
grid
01234000000101100201010300010400000

The upper-left three-cell component and the right two-cell component are separate, and neither touches the boundary.

Example 2

grid = ["111","101","111"]return = 0
grid
012011111012111

The only land component touches the boundary, so it is not isolated.

Constraints

  • 1 <= grid.length <= 300
  • 1 <= grid[i].length <= 300, and all rows have equal length
  • Every character is '0' or '1'

More Microsoft Phone Screen questions

  • Config Store with Priority OverridesPHONE SCREEN · Seen Nov 2026
  • Corporation Reporting LinesPHONE SCREEN · Seen Oct 2026
  • Random Forest Classifier from ScratchPHONE SCREEN · Seen Oct 2026
  • Least Recently Used CacheOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Greedy and Beam Sentence DecodingPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Top K Frequent ElementsPHONE SCREEN · Seen Sep 2026
  • 3SumPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Arithmetic Expression EvaluatorPHONE SCREEN · Seen Sep 2026
  • Employee Hierarchy Cycle and Depth AnalysisPHONE SCREEN · Seen Sep 2026
  • Most Visited String SectorsPHONE SCREEN · Seen Sep 2026

Similar questions at other companies

  • Number of IslandsAmazon · PHONE SCREEN · ONSITE INTERVIEW
  • Max Area of Island Without Changing the GridFlexport · PHONE SCREENFlexport interview questions
  • Count Enclosed Freshwater RegionsGoogle · PHONE SCREEN · ONSITE INTERVIEWGoogle 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
  • Pacific Atlantic Water FlowAnduril · PHONE SCREENAnduril interview questions
  • Grid Pathfinding with Obstacles (DFS)Roblox · PHONE SCREEN · ONSITE INTERVIEWRoblox interview questions
  • Number of IslandsGoldman Sachs · OA · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions
  • House Bounds in a Ragged GridRippling · OA · PHONE SCREENRippling interview questions

Interview reports that mention this question

  • Microsoft AI/ML Intern Interviews: 114 Experiences (Part 1 of 2)

Microsoft interview experiences

  • Microsoft OA Questions, October 2026: 4 Experiences
  • Microsoft Experienced SWE Phone Screen: 1 Experience
  • Microsoft Explore and Student SWE: 12 Experiences (Part 6 of 6)
  • Microsoft SWE Intern, Early 2025: 41 Experiences (Part 5 of 6)
  • Microsoft SWE Intern, Mid 2025: 42 Experiences (Part 4 of 6)
All Microsoft interview questionsSee Microsoft hiring insights
Saved
class Solution {
    public int countIsolatedIslands(String[] grid) {
      // Write your code here.
    }

}
Checking account…