Amazon interview question

Question on array and Tree