Pergunta de entrevista da empresa Genesys

Write a flatten function, given a (possibly) multi-dimensional array as a parameter.

Resposta da entrevista

Sigiloso

21 de fev. de 2020

I used tail recursion, passing in the orginal array and an accumulator array. On every call, I would add the head to the accumulator array if it was not an array, and recursively call the function if the head was an array. I would remove the head on every recursive call, until the original array had no more elements, then I returned the accumulator array.