Amazon Time and Space complexity
Anonymous User
205

What is the time and space complexity for this function?

var recursion = (list) => {
if(list.length === 1){
return list[0];
} else {
let result = [];
var allRest = recursion(list.slice(1))
for(var i=0; i<allRest.length; i++){
for(var j=0; j<list[0].length; j++){
result.push(list[0][j] + allRest[i]);
}
}
return result
}

}

var allArrays = [
['a', 'b'],
['c'],
['d', 'e', 'f'],
['x','y','z']
]

console.log(recursion(allArrays))

Comments (0)