1367. Police Distance
Description 中文 English Given a matrix size of n x m , element 1 represents policeman, -1 represents wall and 0 represents empty. Now please output a matrix size of n x m , output the minimum distance between each empty space and the nearest policeman Given a matrix size of n x m , n <= 200,m <= 200 . We guarantee that each empty space can be reached by one policeman at least. Have you met this question in a real interview? Yes Problem Correction Example Given mat = [ [0, -1, 0], [0, 1, 1], [0, 0, 0] ] return [[2,-1,1],[1,0,0],[2,1,1]] . The distance between the policeman and himself is 0, the shortest distance between the two policemen to other empty space is as shown above Given mat = [ [0, -1, -1], [0, -1, 1], [0, 0, 0] ] return [[5,-1,-1],[4,-1,0],[3,2,1]] 和walls and gates一样,这样额外做一个状态matrix,把police点定义为0,空闲点定义为inf。 ...