Question d’entretien chez Paytm

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