Pregunta de entrevista de Google

Leetcode hard, a novel tree problem.