Loading repovive.com/problems/faang/3
All zombies spread simultaneously every hour; not one at a time. Think about what that means for the underlying graph problem: every zombie cell is equally a starting point for infection, all beginning at the same moment.
Hint 1: Seed a BFS queue with every zombie cell at once, each at time 0. Expand outward level by level; each level represents one additional hour of simultaneous spread.
Hint 2: A human cell's infection time equals its shortest distance to the nearest zombie source. The answer is the maximum such distance across all human cells.
Hint 3: Before starting BFS, check the impossible case: if any human cells exist but no zombie cells do, return −1 immediately.