PayPal interview question

Convert from tree to array