Domanda di colloquio di IXL Learning

One medium leetcode question with follow up.