Javascript ES6 simple solution
\nvar matrixReshape = function (nums, r, c) {\n  var arr = nums.flat();\n  if (r * c != arr.length) return nums;\n\n  var res = [];\n  while (arr.length) res.pu
```\nvar matrixReshape = function (nums, r, c) {\n  var arr = nums.flat();\n  if (r * c != arr.length) return nums;\n\n  var res = [];\n  while (arr.length) res.push(arr.splice(0, c));\n  return res;\n};\n```
['JavaScript']