Plant Infection Simulation, Part 4: Death Countdown
Updated
Problem statement
This part adds a death countdown to the infection-and-recovery simulation.
Each input cell is X (infected), . (healthy), or I (immune). Immune cells never become infected and never transmit infection. Dead cells are terminal and never transmit infection.
Daily Update Rules
At the start of each day, count infected cells among each cell's eight horizontal, vertical, and diagonal neighbors. Using that start-of-day state:
Examples
Example 1
grid = ["X."]infectionThreshold = 2duration = 1deathThreshold = 1return = [2, 1]On day 1, the healthy cell has one infected neighbor, so it starts a death countdown but does not meet the infection threshold. The initial infection recovers. The countdown finishes at the end of day 2, producing one death.
Unlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- Worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$99 billed yearly — or $19 month-to-month. Cancel anytime.
More OpenAI Phone Screen questions
- Rectangle Point Coverage CountsPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Sparse Plant Infection SimulationPHONE SCREEN · ONSITE INTERVIEW · Seen Dec 2026
- Prefix Matrix Products and AutogradPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Streaming Entropy, Part 1: Batch EntropyPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Streaming Entropy, Part 2: Numerically Stable EntropyPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Streaming Entropy, Part 3: Block-wise EntropyPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Streaming Entropy, Part 4: Stable Streaming EntropyPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Secret Number Search with One-Call-Delayed FeedbackPHONE SCREEN · Seen Nov 2026
- Determine the Winner of Three-Card HandsPHONE SCREEN · Seen Nov 2026
- Grid Infection with Recovery After D DaysPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Multi-Head Attention Forward PassMeta · PHONE SCREEN · ONSITE INTERVIEWMeta interview questions
- Implement Multi-Head AttentionByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
- Count Islands from Streaming RowsAmazon · ONSITE INTERVIEW
- Zigzag Board Adjacent SwapsUber · PHONE SCREENUber interview questions
- Cache Shared Image Pipeline PrefixesAnthropic · ONSITE INTERVIEWAnthropic interview questions
- Cats, Rabbits, and Snails Board GameAsana · ONSITE INTERVIEW
- Ultimate Tic-Tac-Toe Move SimulatorHebbia · PHONE SCREEN
- Transformer Attention and SwiGLU Forward PassGoogle · ONSITE INTERVIEWGoogle interview questions
- Self-Attention and Causal Masked Self-AttentionMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
- 2D Convolution Layer Forward PassWaymo · PHONE SCREENWaymo interview questions