Pregunta de entrevista de Thought Machine

to answer an algorithm question