Question d’entretien chez Amazon

Tree based Leetcode quesiton, probably easy or medium.