← Openai Interview Insights

Openai·Machine Learning Engineer·Technical Phone Screen·Senior

SeniorRejected
May 2026

Summary

OpenAI ML Engineer interview that went about as well as you'd expect when you run out of time on a coding problem. Two-part simulation question that started reasonable and escalated fast, and I didn't make it through everything they had planned.

Questions Asked (2)

Q1

Given an M by N grid where each cell is either infected (X) or susceptible (*), simulate the spread of infection day by day. A susceptible cell becomes infected if at least K of its 8 neighbors are infected. Return the number of days until the grid stops changing.

Algorithms & Data Structures
Author's notes

Got through this part okay.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Use a BFS-like simulation where each day you compute the next state of the grid based on the current state, counting infected neighbors for each susceptible cell. Continue until no cell changes, and return the number of days elapsed. Optimize by only checking cells that are susceptible and have at least one infected neighbor.

Pro tip: Clarify edge cases upfront: what if K=0 (all cells become infected immediately) or K>8 (no spread)? Also discuss time complexity and potential optimizations like using a queue for active cells.

1. Clarify requirements and edge cases

Confirm the rules: infection spreads to susceptible cells with at least K infected neighbors among 8. Discuss edge cases like K=0, K>8, all infected initially, or no infected cells.

2. Choose simulation strategy

Decide between naive full-grid scan each day vs. optimized approach tracking only cells that could change. Explain trade-offs in time and space complexity.

3. Implement day-by-day simulation

For each day, compute the next state by checking each susceptible cell's 8 neighbors. Use a separate grid or in-place update with careful handling to avoid using updated values within the same day.

4. Detect termination and count days

After each day, compare the new grid with the previous. If unchanged, stop and return the number of days. Otherwise, increment day count and continue.

5. Analyze complexity and optimize

Discuss time complexity O(days * M * N) and potential optimizations like using a queue of active cells or early termination when no new infections occur.

Key Points to Mention

  • Simultaneous update: all cells change based on the previous day's state, not the current one.
  • Neighbor counting: consider all 8 directions, handle boundaries carefully.
  • Termination condition: stop when no cell changes in a day.
  • Edge cases: K=0, K>8, empty grid, no initial infected cells.
  • Optimization: track only susceptible cells with infected neighbors to reduce redundant checks.
  • Time and space complexity: O(days * M * N) time, O(M * N) space for the grid.

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

Q2

Extend the simulation: after a cell has been infected for D days, it becomes immune (I) on day D+1. Immune cells can't be infected and don't spread infection. Now return the number of days until herd immunity, meaning no infected cells remain.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

This is where things fell apart for me.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the grid as a state machine with susceptible, infected, and immune cells, tracking infection duration per cell. Simulate day by day, updating states based on neighbor infection and immunity timers, until no infected cells remain. Return the number of days elapsed.

Pro tip: Clarify edge cases upfront: initial infected cells, D=0, and whether immunity is permanent. Also discuss time/space complexity and potential optimizations like event-driven simulation or using a queue for infected cells.

1. Define states and transitions

Represent each cell as S, I, or Im. Define rules: S becomes I if adjacent to I; I becomes Im after D days; Im never changes.

2. Initialize grid and tracking

Set initial infected cells and record infection start day for each. Use a 2D array for states and another for infection day or remaining days.

3. Simulate day by day

For each day, update states: newly infected cells from previous day's spread, and infected cells that reach D days become immune. Stop when no infected cells remain.

4. Return days until herd immunity

Count the number of days simulated until the infected count reaches zero. Return that count.

Key Points to Mention

  • State transition rules and immunity duration
  • Data structures for efficient neighbor checks and state updates
  • Time and space complexity of the simulation
  • Handling of edge cases (e.g., no initial infected, D=0, grid boundaries)
  • Potential optimizations for large grids (e.g., event-driven simulation, BFS-like propagation)
  • Clarification of herd immunity definition: no infected cells remain

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