Flatten a nested array with custom ordering (top-level first, then nested) · InterviewLane