let arrs = [
[
[1, 1, 1, 1],
[2, 2, 2, 2],
[3, 3, 3, 3]
],[
[4, 4, 4, 4, 4 ,4],
[5, 5, 5, 5],
[6, 6, 6, 6, 6],
[7, 7, 7, 7],
[8, 8]
],[
[9, 9, 9, 9],
[10, 10, 10, 10],
[11, 11, 11, 11, 11, 11],
[12, 12, 12, 12]
],
];
let arr = [
[1, 1, 1, 1, 4, 4],
[2, 2, 2, 2],
[3, 3, 3, 3, 6, 11],
[7, 7, 7, 7],
[8, 8]
]
const result = arrs.reduce(
(acc, arr) => (arr.forEach((n, i) => acc[i].push(...n.slice(acc[i].length))), acc),
Array.from({ length: Math.max(...arrs.map(arr => arr.length)) }, () => [])
);
const result = arrs.reduce((acc, arr) => (
arr.forEach((n, i) => (
acc[i] = acc[i] || [],
n.forEach((m, j) => acc[i][j] = acc[i][j] || m)
)),
acc
), []);
arrs.reduce((acc, curr) => {
curr.forEach((item, i) => {
acc[i] = acc[i] || [];
acc[i] = [...acc[i], ...item.slice(acc[i].length)];
});
return acc;
}, []);