Unknown's avatar

867. Transpose Matrix

867. Transpose Matrix

class Solution {
    public int[][] transpose(int[][] A) {
        int [][] out = new int[A[0].length][A.length];
        for (int iA = 0; iA < A.length; iA++ )
            for (int jA =0; jA < A[iA].length; jA++)
                        out[jA][iA] = A[iA][jA];
        return out;
    }
}

Leave a comment