Pregunta de entrevista de UBS

leetcode easy medium question that wa bit difficult