public boolean ok(String[] board,int row, int col,int n){
        for(int i =0 ; i < row; i++){
            // 确保列上不会重复
            if(board[i].charAt(col) == 'Q')
                return false;
            // 确保对角线不会重复
            int temp = col - row +i;
            if(temp >=0 && board[i].charAt(temp) == 'Q')
                return false;
            int temp1 = col + row -i;
            if(temp1 < n && board[i].charAt(temp1) == 'Q')
                return false;
        }
        return true;
    }