Problem: You have a nested array and you need all elements to be flat, no sub arrays. Ex: [1, 2, [3, [4, 5]]] There are some hurdles to jump over to make this truly efficient. [].concat based solutions: not efficient as they create new arrays and that consumes precious memory …