Dassault Systèmes interview question

code to flatten the array