Google interview question

leetcode tree question, one question never seen before.