package com.fishercoder.solutions;

public class _566 {

    public static class Solution1 {
        public int[][] matrixReshape(int[][] nums, int r, int c) {
            if (nums == null || nums.length == 0) {
                return nums;
            }
            int m = nums.length;
            int n = nums[0].length;
            if (r * c > m * n) {
                return nums;
            }
            int k = 0;
            int[][] result = new int[r][c];
            for (int i = 0; i < r; i++) {
                for (int j = 0; j < c; j++, k++) {
                    result[i][j] = nums[k / n][k % n];
                }
            }
            return result;
        }
    }
}

@@ -131,20 +131,19 @@
 int%5B%5D%5B%5D 
-nums
+mat
 , int r,
@@ -168,20 +168,19 @@
     if (
-nums
+mat
  == null
@@ -183,20 +183,19 @@
 null %7C%7C 
-nums
+mat
 .length 
@@ -217,36 +217,35 @@
          return 
-nums
+mat
 ;%0A            %7D%0A
@@ -264,20 +264,19 @@
 int m = 
-nums
+mat
 .length;
@@ -296,20 +296,19 @@
 int n = 
-nums
+mat
 %5B0%5D.leng
@@ -367,20 +367,19 @@
  return 
-nums
+mat
 ;%0A      
@@ -585,12 +585,11 @@
 %5D = 
-nums
+mat
 %5Bk /
@@ -674,11 +674,584 @@
  %7D%0A    %7D
+%0A%0A    public static class Solution2 %7B%0A        public int%5B%5D%5B%5D matrixReshape(int%5B%5D%5B%5D mat, int r, int c) %7B%0A            int m = mat.length;%0A            int n = mat%5B0%5D.length;%0A            if (m * n != r * c) %7B%0A                return mat;%0A            %7D%0A            int%5B%5D%5B%5D reshapedMat = new int%5Br%5D%5Bc%5D;%0A            for (int i = 0; i %3C m; i++) %7B%0A                for (int j = 0; j %3C n; j++) %7B%0A                    int index = i * n + j;%0A                    reshapedMat%5Bindex / c%5D%5Bindex %25 c%5D = mat%5Bi%5D%5Bj%5D;%0A                %7D%0A            %7D%0A            return reshapedMat;%0A        %7D%0A    %7D
 %0A%7D%0A

add one more solution for 566