Arrange every value in original into a matrix with m rows and n columns, preserving its order. Fill the first row from left to right, then the second row, and continue in this order. Return the matrix if all values fit exactly; otherwise, return an empty matrix.
Example 1:
Input: original = [5,6,7,8,9,10]
m = 2
n = 3
Output: [[5,6,7],[8,9,10]]Explanation: The first three values form [5, 6, 7], and the next three form [8, 9, 10]. These two rows use every value in order.
Example 2:
Input: original = [4,2,9]
m = 3
n = 1
Output: [[4],[2],[9]]Explanation: Each row contains one value, so the rows are [4], [2], and [9], in the same order as the original array.
Example 3:
Input: original = [1,2,3]
m = 2
n = 2
Output: []Explanation: A matrix with two rows and two columns needs four values, but only three are available. Return an empty matrix.
Constraints:
1 <= original.length <= 500001 <= original[i] <= 1000001 <= m, n <= 40000