Pregunta de entrevista de Google

leetcode tree question, one question never seen before.