@@ -0,0 +1,1470 @@
+%22%22%22%0AGiven a 2D board containing 'X' and 'O' (the letter O), capture all regions%0Asurrounded by 'X'.%0A%0AA region is captured by flipping all 'O's into 'X's in that surrounded region.%0A%0AFor example,%0A    X X X X%0A    X O O X%0A    X X O X%0A    X O X X%0A%0AAfter running your function, the board should be:%0A%0A    X X X X%0A    X X X X%0A    X X X X%0A    X O X X%0A%22%22%22%0Aclass Solution(object):%0A    def solve(self, board):%0A        %22%22%22%0A        :type board: List%5BList%5Bstr%5D%5D%0A        :rtype: void Do not return anything, modify board in-place instead.%0A        %22%22%22%0A        x = len(board)%0A        if x %3C= 2:%0A            return%0A        y = len(board%5B0%5D)%0A        if y %3C= 2:%0A            return%0A        bfs = collections.deque()%0A        for i in range(x):%0A            for j in range(y):%0A                if i == 0 or i == x - 1 or j == 0 or j == y - 1:%0A                    if board%5Bi%5D%5Bj%5D == 'O':%0A                        bfs.append((i, j))%0A%0A        while bfs:%0A            i, j = bfs.popleft()%0A            if i %3E= 0 and i %3C x and j %3E= 0 and j %3C y:%0A                if board%5Bi%5D%5Bj%5D == 'O':%0A                    bfs.append((i - 1, j))%0A                    bfs.append((i + 1, j))%0A                    bfs.append((i, j - 1))%0A                    bfs.append((i, j + 1))%0A                    board%5Bi%5D%5Bj%5D = 'B'%0A%0A        for i in range(x):%0A            for j in range(y):%0A                if board%5Bi%5D%5Bj%5D == 'O':%0A                    board%5Bi%5D%5Bj%5D = 'X'%0A                if board%5Bi%5D%5Bj%5D == 'B':%0A                    board%5Bi%5D%5Bj%5D = 'O'

add 130