def wallsAndGates(self, mat):
        """
        bfs
        O(mn), abstract level

        reference: https://leetcode.com/discuss/60170/6-lines-o-mn-python-bfs
        :type mat: List[List[int]]
        :rtype: void Do not return anything, modify rooms in-place instead.
        """
        q = [(i, j) for i, row in enumerate(mat) for j, val in enumerate(row) if val == 0]
        for i, j in q:  # iterator
            for d in self.dirs:
                i1, j1 = i+d[0], j+d[1]
                if 0 <= i1 < len(mat) and 0 <= j1 < len(mat[0]) and mat[i1][j1] > mat[i][j]+1:
                    mat[i1][j1] = mat[i][j]+1
                    q.append((i1, j1))
dataset/ETHPy150Open algorhythms/LeetCode/286 Walls and Gates.py/Solution.wallsAndGates/original