Pergunta de entrevista da empresa Google

DSA tree question, medium-hard leetcode difficulty.