Pregunta de entrevista de Thoughtworks

First and second were coding rounds