题130. 被围绕的区域

Java

class Solution {
    public void solve(char[][] board) {
        if(board.length == 0 ) return;
        int row = board.length;
        int col = board[0].length;
        
        for (int i = 0; i < row; i++) {
            if (board[i][0] == 'O') helper(board,i,0);
            if (board[i][col-1] == 'O') helper(board,i,col-1);
        }
 
        for (int i = 0; i < col; i++) {
            if (board

猜你喜欢

转载自blog.csdn.net/weixin_43349929/article/details/107927207
今日推荐