image.png

解题思路

image.png

  1. class Solution {
  2. public int[][] transpose(int[][] A) {
  3. int R = A.length, C = A[0].length;
  4. int[][] ans = new int[C][R];
  5. for (int r = 0; r < R; ++r)
  6. for (int c = 0; c < C; ++c) {
  7. ans[c][r] = A[r][c];
  8. }
  9. return ans;
  10. }
  11. }