Skip to content

2022-convert-1d-array-into-2d-array

DevGod
DevGod
Vtuber
/**
* @param {number[]} original
* @param {number} m
* @param {number} n
* @return {number[][]}
*/
var construct2DArray = function(original, m, n) {
let chuncked = _.chunk(original, n);
if( chuncked.length !== m){
return [];
}
if( chuncked[0].length !== n){
return [];
}
return chuncked;
};