In my experience, when interviewers do grade based on algorithmic performance, they want to see low time complexity, and care much less about space complexity.
In this example, you could actually accomplish the solution in linear time using a hashmap and keeping track of the min/max vals; O(max-min)
Something like...
let map = {};
let minVal = null;
let maxVal = null;
for (let a of arrays) {
for (let v of a) {
if (minVal === null) minVal = v;
else minVal = Math.min(minVal, v);
if (maxVal === null) maxVal = v;
else maxVal = Math.max(maxVal, v);
if (!map[v]) map[v] = 0;
map[v]++;
}
}
let result = [];
for (let i = minVal; i <= maxVal; i++) {
for (let n = map[i] || 0; n > 0; n--) {
result.push(i);
}
}
return result;
Haven't ran the above, just an example