Reported September 2026
Oraclebreadth first search

Island Count and Maximum Area

Reported by candidates from Oracle's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Oracle OA. Under 2s to a working solution.
Founder's read

The detail that matters in this Oracle problem is the return value: a two-element array, [islandCount, maximumArea], and [0,0] when the grid has no land. Oracle candidates reported it in September 2026. It's a grid flood fill, and BFS or DFS both work. Islands connect horizontally and vertically only, so no diagonals. If you've seen Max Area of Island, you already know 90% of this. The twist is tracking the count alongside the max. If your mind goes blank mid-assessment, StealthCoder is a desktop overlay the proctor can't see, and it can hand you the solution live.

The problem

Given a rectangular binary matrix grid, find all islands. An island is a maximal group of 1 cells connected horizontally or vertically.
Return [islandCount, maximumArea]. The area of an island is its number of cells. Return [0,0] when the grid contains no land.

Function
islandStats(grid: int[][]) → int[]

Examples
Example 1
grid = [[1,1,0,0],[0,1,0,1],[1,0,0,1]]
return = [3,3]
There are three islands; the island in the upper-left has area 3 and is the largest.
Example 2
grid = [[0,0],[0,0]]
return = [0,0]
No land cell exists.

Constraints
1 <= grid.length, grid[i].length <= 300.
Every row has the same length.
Every cell is 0 or 1.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is one pass over the grid. Scan every cell. When you hit a 1, that's a new island: increment the count, then flood fill from it with BFS or DFS, counting cells as you go and marking each visited cell as 0 so you never revisit it. After the fill, update maxArea with the size you counted. Each cell gets visited a constant number of times, so it's O(rows*cols) time. The common pitfall is recursion depth. The grid can reach 300 by 300, which is 90,000 cells, and a recursive DFS on one giant island can blow the stack in some languages. Use an iterative BFS with a queue or an explicit stack. Other mistakes: counting diagonals, forgetting to mark cells on push instead of on pop, and returning [0,0] wrongly. If you freeze on the live OA, StealthCoder is the hedge that surfaces the working flood fill.

Memorize the pattern. If you can't, run StealthCoder. The proctor sees the IDE. They don't see what's behind it.

If this hits your live OA

You can drill Island Count and Maximum Area cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as max area of island. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Oracle's OA.

Oracle reuses patterns across OAs. Made by an engineer who treats the OA as theater. If yours is tonight, you don't have time to grind. You have time to hedge. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Island Count and Maximum Area FAQ

How hard is the Oracle island count and max area problem really?+

It's medium at worst, and easy if you've done grid flood fill before. You combine Number of Islands with Max Area of Island in one pass. The logic is short. Most failures come from edge handling and stack depth, not from the idea.

What's the trick to solving it?+

Scan the grid, and on each unvisited 1, start a BFS or DFS that counts cells and sinks them to 0. Increment the island counter once per fill and track the largest fill size. That gives both answers in a single pass.

Should I use BFS or DFS?+

Either works, but BFS with a queue is safer. Grids up to 300 by 300 can make one island 90,000 cells, and recursive DFS may overflow the call stack. If you want DFS, write it with an explicit stack.

Do I need a separate visited array?+

No. Setting visited land cells to 0 in place works and saves memory. If the assessment says not to mutate input, copy the grid or use a boolean visited matrix. Both stay linear in the grid size.

How do I prepare for this in 48 hours?+

Write the iterative BFS flood fill from scratch twice. Test it on an all-zero grid, a single-cell grid, and a full-land grid. Check the four-direction neighbor bounds. That covers nearly every bug this problem produces.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Oracle.

OA at Oracle?
Invisible during screen share
Get it