Pregunta de entrevista de Palantir Technologies

Algorithm question using tree data structure