Pregunta de entrevista de Google

Problem about Tree structure (Online Coding)