package leetcode;

/**
 * https://leetcode.com/problems/transpose-matrix/
 */
public class Problem868 {
    public int[][] transpose(int[][] A) {
        // TODO
        return null;
    }

    public static void main(String[] args) {
        Problem868 prob = new Problem868();
        // [1, 4, 7],
        // [2, 5, 8],
        // [3, 6, 9]
        System.out.println(prob.transpose(new int[][]{
            {1, 2, 3},
            {4, 5, 6},
            {7, 8, 9}
        }));
        // [1, 4],
        // [2, 5],
        // [3, 6]
        System.out.println(prob.transpose(new int[][]{
            {1, 2, 3},
            {4, 5, 6}
        }));
    }
}

@@ -12,16 +12,42 @@
 tcode;%0A%0A
+import java.util.Arrays;%0A%0A
 /**%0A * h
@@ -177,43 +177,553 @@
     
-// TODO%0A        return null;%0A    %7D%0A
+int nRow = A.length;%0A        int nCol = 0;%0A        if (A.length %3E 0) %7B%0A            nCol = A%5B0%5D.length;%0A        %7D%0A        int%5B%5D%5B%5D result = new int%5BnCol%5D%5BnRow%5D;%0A        for (int row = 0; row %3C nRow; row++) %7B%0A            for (int col = 0; col %3C nCol; col++) %7B%0A                result%5Bcol%5D%5Brow%5D = A%5Brow%5D%5Bcol%5D;%0A            %7D%0A        %7D%0A        return result;%0A    %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   
@@ -881,34 +881,21 @@
         
-System.out.
 print
-ln
 (prob.tr
@@ -1060,34 +1060,21 @@
         
-System.out.
 print
-ln
 (prob.tr

Solve problem 868