#33 - Convert 1D Array to 2D Array
You are given a 1D array containing integers and the number of rows m
and number of columns n
of the desired 2D array. Your task is to implement a function to convert the 1D array into a 2D array of size m x n
row-wise.
If the total number of elements in the 1D array is less than m x n
, fill the remaining cells with 0. If the total number of elements is greater than m x n
, ignore the excess elements.
Example 1
Input
Output
Example 2
Input
Output
Example 3
Input
Output
Last updated