Bloomberg interview question

leetcode flattern tree