Easy-to-understand python solution
\nclass Solution(object):\n    def matrixReshape(self, nums, r, c):\n        """\n        :type nums: List[List[int]]\n        :type r: int\n        :type c: in
```\nclass Solution(object):\n    def matrixReshape(self, nums, r, c):\n        """\n        :type nums: List[List[int]]\n        :type r: int\n        :type c: int\n        :rtype: List[List[int]]\n        """\n        if len(nums) * len(nums[0]) != r * c:\n            return nums\n            \n        ans = [[]]\n        for i in range(len(nums)):\n            for j in range(len(nums[0])):\n                k = nums[i][j]\n                if len(ans[-1]) < c:\n                    ans[-1].append(k)\n                else:\n                    ans.append([k])\n        return ans\n```
['Python']