balena interview question

Flatten nested array