def bfs_deque(self, rooms, x, y):
        from collections import deque

        m = len(rooms)
        n = len(rooms[0])
        q = deque()
        q.append((x, y, 0))
        while q:
            i, j, level = q.popleft()
            rooms[i][j] = min(rooms[i][j], level)
            for d in self.dirs:
                i_t, j_t = i+d[0], j+d[1]
                if 0 <= i_t < m and 0 <= j_t < n and rooms[i_t][j_t] != -1 and rooms[i_t][j_t] >= level+1:
                    q.append((i_t, j_t, level+1))
dataset/ETHPy150Open algorhythms/LeetCode/286 Walls and Gates.py/Solution_slow.bfs_deque/original