Company: Amazon
Difficulty: medium
Problem Statement A cold-storage warehouse keeps perishable goods in a refrigerated section laid out as an 'm x n' grid, where each cell holds one of three values: '0' representing an empty bay '1' representing a bay with a fresh perishable shipment '2' representing a bay with a spoiled shipment (its cooling unit has failed) Whenever a cooling unit fails, the resulting heat spreads through shared ventilation to neighboring bays. Every minute, any fresh shipment sitting 4-directionally adjacent to a spoiled bay turns spoiled as well. Report the fewest number of minutes needed until no bay still holds a fresh shipment. If some fresh shipment can never be reached, report '-1'.