[Python] - Clean & Simple - O(m*n) Solution
Complexity\n- Time complexity: O(mn)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(mn)\n Add your space complexity here, e.g. O(n) \n\n# 
# Complexity\n- Time complexity: $$O(m*n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(m*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        m = len(mat)\n        n = len(mat[0])\n\n        if m * n != r * c :\n            return mat \n\n        cnt = 0\n        ans = []\n        row = []\n        for i in range(m):\n            for j in range(n):\n                row.append(mat[i][j])\n                cnt+=1\n                if cnt == c:\n                    ans.append(row)\n                    row = []\n                    cnt = 0\n        return ans\n```\n## Numpy:\n```\nimport numpy as np\nclass Solution:\n    def matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n        try:\n            return np.reshape(mat, (r, c)).tolist()\n        except:\n            return mat\n```
['Python3']