Hotbit Infotech interview question

Flatten array problem from leetcode