Python 3 (84ms) | O(m*n) | Creating New Matrix & Inserting Our Values | Easy Solution
Creating New Matrix of 0s and then Inserting our values one by one.\nTakes O(m * n) Time & Space.\n\n\nclass Solution:\n    def matrixReshape(self, mat: List[Li
Creating New Matrix of 0s and then Inserting our values one by one.\nTakes O(m * n) Time & Space.\n\n```\nclass Solution:\n    def matrixReshape(self, mat: List[List[int]], r: int, c: int) -> List[List[int]]:\n        n,m=len(mat[0]),len(mat)\n        if n*m!=r*c:\n            return mat\n        k=0\n        tmp=[]\n        output=[[0 for i in range(c)] for j in range(r)]\n        for i in mat:\n            for j in i:\n                tmp.append(j)\n        for i in range(r):\n            for j in range(c):\n                output[i][j] = tmp[k]\n                k+=1\n        return output\n```
['Matrix', 'Python']