Allen Institute interview question

Asked a tree question from leetcode.