## Question 1 Given a matrix, `mat` = [[0, 0, 0], [0, 1, 0], [1, 0, 0]], find the matrix that contains the distance of the nearest 0 for each cell. ### Options 1. [[0, 0, 0], [0, 0, 0], [0, 0, 0]] Incorrect From cell (1, 1), we have to move one cell in any direction to get to the closest 0. ---------------------------- 2. [[0, 0, 0], [0, 1, 0], [1, 0, 0]] Correct From cell (1, 1), we have to move one cell in any direction to reach the closest 0. This is the same for cell (2, 0). ---------------------------- 3. [[0, 1, 0], [0, 1, 0], [0, 1, 0]] Incorrect Cell (0, 1) in the input is itself 0, so we don’t need to move to a different cell to find a 0. ---------------------------- 4. [[1, 0, 1], [0, 1, 0], [1, 0, 1]] Incorrect Cell (0, 0) in the input is itself 0, so we don’t need to move to a different cell to find a 0. ---------------------------- --------------------------------------------- ## Question 2 Given a matrix, `mat` = [[0, 0, 0], [0, 1, 0], [1, 1, 1]], find the matrix that contains the distance of the nearest 0 for each cell. ### Options 1. [[0, 0, 0], [0, 1, 0], [1, 2, 1]] Correct This is correct. ---------------------------- 2. [[0, 2, 0], [0, 1, 1], [1, 2, 1]] Incorrect Cell (0, 1) in the input is itself 0, so we don’t need to move to a different cell to find a 0. ---------------------------- 3. [[0, 0, 0], [0, 1, 0], [1, 1, 1]] Incorrect From cell (2, 1), we have to move two cells in any direction to get to the nearest 0. ---------------------------- 4. [[1, 2, 0], [1, 1, 1], [1, 1, 2]] Incorrect Cell (0, 0) in the input is itself 0, so we don’t need to move to a different cell to find a 0. ---------------------------- --------------------------------------------- ## Question 3 Given a matrix, `mat` = [[0, 0, 1], [1, 1, 1], [1, 0, 1]], find the matrix that contains the distance of the nearest 0 for each cell. ### Options 1. [[0, 0, 0], [0, 1, 0], [1, 2, 1]] Incorrect Cell (2, 1) in the input is itself 0, so we don’t need to move to a different cell to find a 0. ---------------------------- 2. [[0, 0, 1], [0, 1, 1], [1, 2, 1]] Incorrect From cell (1, 0), we have to move one cell above to get to the closest 0. ---------------------------- 3. [[0, 0, 1], [1, 1, 2], [1, 0, 1]] Correct This is correct. ---------------------------- 4. [[0, 0, 0], [0, 0, 0], [0, 0, 0]] Incorrect From cell (0, 2), we have to move one cell to the left to get to the closest 0. ---------------------------- ---------------------------------------------