Mathworks
1 DSA problems asked in Mathworks coding interviews
1 Easy
0 Medium
0 Hard
All Categories
All
1 problem
Matrix1
Reshape the Matrix
Easy
You are given an `m x n` matrix `mat` and two integers `r` and `c`. Reshape `mat` into a new `r x c` matrix that holds the same values in the same row-major order: read `mat` row by row, left to right, and fill the new matrix row by row in that order. If an `r x c` matrix cannot hold exactly the same number of values (`m * n != r * c`), return the original `mat` unchanged.