Python solution
I know that the code looks ugly, but it is good enough for a beginner like me :)\n\nclass Solution(object):\n    def matrixReshape(self, nums, r, c):\n        "
I know that the code looks ugly, but it is good enough for a beginner like me :)\n```\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        nrows = len(nums)\n        ncols = len(nums[0])\n        \n        if nrows * ncols == r * c:\n            onedArray = []\n            reshaped = [[0] * c for i in range(r)]\n            for x in nums:\n                onedArray += x\n            for index, item in enumerate(onedArray):\n                placeRow = index / c\n                placeCol = index % c\n                reshaped[placeRow][placeCol] = item\n            return reshaped\n        else:\n            return nums\n```
[]