Pregunta de entrevista de Bloomberg

one from the leetcode question