Reshape the Matrix
Updated Feb 24, 2026
Problem
Reshape matrix to r x c if possible, else return original.
Constraints
1 <= m, n <= 100
Examples
Example 1
Input:
{"mat": [[1, 2], [3, 4]], "r": 1, "c": 4}
Output:
[[1, 2, 3, 4]]
Function Signature
def matrixReshape(self, mat: list[list[int]], r: int, c: int) -> list[list[int]]
How to Submit
Implement a Solution class with a matrixReshape method.
Your method will be called with the input parameters and should return the answer.