Pregunta de entrevista de IXL Learning

One medium leetcode question with follow up.