Paytm interview question

medium hard coding question from trees , Linked list and array