Pregunta de entrevista de Smoothstack

It was a coding interview.