Pregunta de entrevista de Bloomberg

Both are tree style problems