Algorithm · Lyft · Medium
Requirements You are given a 2-D grid in which each cell is either empty (0), fresh (1), or infected (2). Every minute, all currently infected cells simultaneously spread the infection to their directly adjacent fresh neighbors (up, down, left, and right). Your task is to determine how many minutes are needed for all fresh cells to become infected, or return -1 if some fresh cells can never be reached. Function signature: Be ready to explain: how the initial BFS queue is…
Checking your access…