package leetcode;

import java.util.Arrays;

/**
 * https://leetcode.com/problems/transpose-matrix/
 */
public class Problem868 {
    public int[][] transpose(int[][] A) {
        int nRow = A.length;
        int nCol = 0;
        if (A.length > 0) {
            nCol = A[0].length;
        }
        int[][] result = new int[nCol][nRow];
        for (int row = 0; row < nRow; row++) {
            for (int col = 0; col < nCol; col++) {
                result[col][row] = A[row][col];
            }
        }
        return result;
    }

    private static void print(int[][] matrix) {
        for (int[] array : matrix) {
            System.out.println(Arrays.toString(array));
        }
        System.out.println();
    }
}

@@ -534,195 +534,7 @@
    %7D
-%0A%0A    private static void print(int%5B%5D%5B%5D matrix) %7B%0A        for (int%5B%5D array : matrix) %7B%0A            System.out.println(Arrays.toString(array));%0A        %7D%0A        System.out.println();%0A    %7D
 %0A%7D%0A

Update problem 868