Pregunta de entrevista de Google

DSA tree question, medium-hard leetcode difficulty.