Paytm Interview Question

medium hard coding question from trees , Linked list and array