Reported September 2026
OpenAIsimulation

Sparse Plant Infection Simulation

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

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

The constraint that kills brute force here is the coordinate space. Plants sit at signed 32-bit coordinates, so a dense grid is impossible, and recoveryDays can hit 10^9, so day-by-day simulation is out too. This OpenAI problem, reported in September 2026, is a sparse grid infection simulation, and it rewards event-driven thinking over ticking a clock. Only listed plants matter, up to 2 * 10^5 of them, each with at most eight neighbors. If you've got the OA coming up, learn the shape of the solution now. StealthCoder is the safety net on the live assessment if you blank on the scheduling part.

The problem

You are given a sparse plant grid. Each row of plants is [row, column, state] for one plant at a unique signed 32-bit coordinate:
0 means healthy;
1 means infected;
2 means immune;
3 means dead.
An unlisted coordinate contains no plant. Only listed plants participate in the simulation.
Day 0 is the supplied state. To advance from day t to day t + 1, read one start-of-day snapshot and apply all changes simultaneously:
A healthy plant becomes infected when at least threshold of its eight neighboring listed plants are infected at the start of the day.
A newly infected plant first contributes to neighbor counts on the next day.
An infected plant contributes for exactly recoveryDays consecutive start-of-day states, including its first infected state, and then becomes immune at the next boundary.
Every initially infected plant starts with the full recoveryDays duration.
Immune and dead plants never change and never count as infected neighbors. Dead plants occur only in the supplied initial state.
Return the earliest nonnegative day after which no current or scheduled future transition can change any plant. An infected plant with remaining infectious days prevents stabilization even when the visible grid does not change on the next boundary.

Function
plantInfectionStabilizationDays(plants: int[][], threshold: int, recoveryDays: int) → int

Examples
Example 1
plants = [[0,0,1],[0,1,0],[0,2,0]]
threshold = 1
recoveryDays = 2
return = 4
The infection moves one position to the right on days 1 and 2. The initially infected plant recovers on day 2, the middle plant on day 3, and the final plant on day 4. No future transition remains after day 4.
Example 2
plants = [[0,0,1],[0,1,0],[1,0,1],[1,1,0]]
threshold = 2
recoveryDays = 1
return = 2
Both healthy plants see the two initially infected plants in their eight-neighbor snapshots, so both become infected on day 1 while the original pair recovers. The new pair recovers on day 2.
Example 3
plants = [[0,0,0],[0,1,2],[1,0,3]]
threshold = 1
recoveryDays = 5
return = 0
There is no infected plant. The healthy plant cannot change, while the immune and dead plants are terminal, so the supplied day-0 state is already stable.

Constraints
1 <= plants.length <= 2 * 10^5.
Each plants[i] is [row, column, state]; coordinates are unique signed 32-bit integers and 0 <= state <= 3.
1 <= threshold <= 8.
1 <= recoveryDays <= 10^9.
The stabilization day fits in a signed 32-bit integer.
Updates are synchronous, use all eight neighboring coordinates, and only listed plants can change.

Reported by candidates. Source: FastPrep

Pattern and pitfall

The trick is to treat this as a BFS-style event simulation over a hash map keyed by coordinate. Precompute each plant's neighbor list once, since only listed plants count. A plant can only become infected when a neighbor's infection count crosses the threshold, so you never scan idle plants. Each infected plant has a known recovery day: infection day plus recoveryDays. Healthy plants infect at most once, so total work is bounded by about 8n events. Process day by day, but jump over empty days using the next scheduled recovery. The pitfall is simultaneity. Read start-of-day state, apply changes after. A newly infected plant counts only the next day. The other trap is the answer: it's the last recovery day or infection day, not the last visible grid change. Infected plants with remaining days block stabilization. If you blank on this, StealthCoder can cover you during the live OA.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Sparse Plant Infection Simulation 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. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

OpenAI reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Sparse Plant Infection Simulation FAQ

What's the trick to the Sparse Plant Infection Simulation?+

Don't simulate a grid. Store plants in a hash map by coordinate, precompute neighbors, and track infected-neighbor counts. Only plants next to a newly active infection need rechecking. Schedule recoveries as events by day so huge recoveryDays values never cause a loop over every day.

Why can't I just simulate every day?+

recoveryDays goes up to 10^9, so ticking one day at a time can blow up. Coordinates are 32-bit, so you can't allocate a grid either. You need to jump between meaningful days, meaning days where something infects or recovers, and only touch affected plants.

How do I get the final answer day?+

It's the last day any transition happens. That includes the final recovery of an infected plant, even if the visible grid doesn't change before it. If nothing is infected at day 0, return 0. Track the max of infection day plus recoveryDays across all infected plants.

What are the common bugs on this problem?+

Applying updates mid-day instead of from a start-of-day snapshot is the big one. Others: letting a newly infected plant count the same day, forgetting initial infections get the full recoveryDays, counting immune or dead neighbors, and using only four directions instead of eight.

How do I prepare in 48 hours for this OpenAI OA?+

Practice sparse-grid problems with a coordinate hash map and neighbor counting, plus a simulation driven by a queue or heap of events. Write the three examples as tests, especially the threshold 2 case. Time yourself on getting the simultaneous update logic right on the first pass.

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

OA at OpenAI?
Invisible during screen share
Get it