Pregunta de entrevista de Paytm

Traverse a tree and maintain array which contains node’s data and depth for each node.