Pregunta de entrevista de Optiver

Tree path based question was asked.