Coding Ninjas interview question

Competitive programming Array Tree