Compute time to infect all cells
Company: OpenAI
Role: Machine Learning Engineer
Category: Coding & Algorithms
Difficulty: hard
Interview Round: Onsite
Quick Answer: This question evaluates competency in modeling and analyzing discrete-time grid-based state propagation with threshold-based infection rules and boundary conditions.
Constraints
- 1 <= n, m <= 200
- grid[i][j] is either 0 or 1
- 0 <= K <= 4
Examples
Input: ([[1,0,0],[0,0,0]], 1)
Expected Output: 3
Explanation: With K = 1, infection spreads outward one layer per step from the initial infected cell. The farthest cell is infected at time 3.