Company: Amazon
Difficulty: medium
Problem Statement A section of the Amazon fulfillment center stores perishable goods in a refrigerated area. The area is represented as an 'm x n' grid where each cell can have 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) When a cooling unit fails, the excess heat spreads through shared ventilation to adjacent bays. Every minute, any fresh shipment that is 4-directionally adjacent to a spoiled bay becomes spoiled. Return the minimum number of minutes that must elapse until no bay contains a fresh shipment. If this is impossible, return '-1'.