Pregunta de entrevista de IBM

Leetcode medium, also looking at personality.