PracHub
QuestionsCoachesLearningGuidesInterview Prep
|Home/Coding & Algorithms/OpenAI

Compute Infection Time in a Grid

Last updated: Apr 19, 2026

Quick Overview

This question evaluates competence in grid-based graph traversal and simulation of propagation dynamics, focusing on state management, time-step modeling, and handling unreachable cells.

  • hard
  • OpenAI
  • Coding & Algorithms
  • Software Engineer

Compute Infection Time in a Grid

Company: OpenAI

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: hard

Interview Round: Technical Screen

You are given an `m x n` grid where each cell is one of the following: - `0`: empty - `1`: healthy - `2`: infected Every minute, each infected cell spreads the infection to its adjacent healthy cells in the four cardinal directions. Return the minimum number of minutes needed until no healthy cells remain. If it is impossible to infect every healthy cell, return `-1`.

Quick Answer: This question evaluates competence in grid-based graph traversal and simulation of propagation dynamics, focusing on state management, time-step modeling, and handling unreachable cells.

Related Interview Questions

  • Consistent Hashing Ring with Virtual Nodes for Shard Rebalancing - OpenAI (hard)
  • Infection Spread Simulation with Death Threshold - OpenAI (medium)
  • Spreading Contagion on a Grid - OpenAI (medium)
  • Streaming Entropy with Numerical Stability - OpenAI (hard)
  • Implement a Distributed Rate Limiter - OpenAI (medium)
|Home/Coding & Algorithms/OpenAI

Compute Infection Time in a Grid

OpenAI logo
OpenAI
Apr 7, 2026, 12:00 AM
hardSoftware EngineerTechnical ScreenCoding & Algorithms
18
0
Practice Read
Loading...

You are given an m x n grid where each cell is one of the following:

  • 0 : empty
  • 1 : healthy
  • 2 : infected

Every minute, each infected cell spreads the infection to its adjacent healthy cells in the four cardinal directions.

Return the minimum number of minutes needed until no healthy cells remain. If it is impossible to infect every healthy cell, return -1.

Submit Your Answer to Earn 20XP

Sign in to leave a comment

Loading comments...

Browse More Questions

More Coding & Algorithms•More OpenAI•More Software Engineer•OpenAI Software Engineer•OpenAI Coding & Algorithms•Software Engineer Coding & Algorithms
PracHub

Master your tech interviews with 8,000+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • AI Coding Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.