Pregunta de entrevista de Clear Labs

It was a leetcode medium question.