← Openai Interview Insights

Openai·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
May 2026

Summary

Interviewed for a software engineer role at OpenAI and got a grid simulation problem that looked deceptively approachable at first. The edge cases are where it gets messy and I definitely underestimated how much the recovery mechanic would complicate things.

Questions Asked (1)

Q1

You're given a 2D grid where cells are either infected, healthy, or immune. Each day, healthy cells adjacent to infected ones become infected. Infected cells recover after exactly D days and can be reinfected later. Immune cells never change. Return the first day where nothing changes between consecutive days.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I spent the first few minutes just staring at the recovery rule because D=0 is a weird edge case where cells infect and recover in the same step.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the grid as a state machine and simulate day-by-day, tracking each cell's infection start day to know when it recovers. Use BFS or multi-source propagation to efficiently update newly infected cells, and stop when the grid state (infected set + recovery timers) is identical to the previous day.

Pro tip: Clarify edge cases upfront—like whether recovery happens before or after new infections on the same day—and mention that you'd use a queue to process only active infected cells, avoiding full-grid scans each day.

1. Clarify rules and edge cases

Ask about recovery timing (e.g., does a cell infected on day 0 recover on day D or D+1?), reinfection conditions, and whether immune cells block adjacency. Confirm that 'nothing changes' means both infection status and recovery timers are unchanged.

2. Choose data structures

Use a 2D array for cell states (0=healthy, 1=infected, 2=immune) and a parallel array for infection start day (or remaining recovery days). Maintain a queue of currently infected cells to process only active infections.

3. Simulate day by day

At each day, process the queue: for each infected cell, if its recovery day is reached, mark it healthy; otherwise, attempt to infect adjacent healthy cells, adding them to the queue with their start day. Track changes to detect stability.

4. Detect stabilization

After each day, compare the current state (infected set and recovery timers) with the previous day. If no changes occurred, return the current day as the first stable day.

5. Analyze complexity and optimizations

Discuss time complexity O(days * active infected cells) and space O(rows*cols). Mention potential optimizations like early termination if no infected cells remain or using a set for infected cells to speed up comparisons.

Key Points to Mention

  • Use BFS/multi-source propagation to simulate infection spread efficiently.
  • Track infection start day per cell to handle recovery after exactly D days.
  • Handle reinfection correctly: a recovered cell can become infected again if adjacent to an infected cell.
  • Detect stability by comparing full state (including recovery timers) between consecutive days.
  • Consider edge cases: no infected cells initially, all immune, D=0, grid boundaries.
  • Discuss time/space complexity and potential optimizations like early termination.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.