Pregunta de entrevista de Amazon

Burning tree question from leetcode