Best python solution easy to understand!!!
\n# Approach\n Describe your approach to solving the problem.  First we should check if it is possible to reshape the given matrix to asked one. Then we make on
\n# Approach\n<!-- Describe your approach to solving the problem. --> First we should check if it is possible to reshape the given matrix to asked one. Then we make one dimensional array from given matrix (flat). After, we add the subarrays which are defined by dividing the flat array into c, r times .\n\n# Complexity\n- Time complexity: O(n)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: O(n)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution:\n    def matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n        if r*c!=len(mat)*len(mat[0]):\n            return mat\n        flat,ans=[],[]\n        for i in mat:\n            flat+=i\n        for i in range(r):\n            ans+=[flat[i*c:i*c+c]]\n        return ans\n        \n```
['Python3']