IXL Learning interview question

Easy/medium leetcode equivalent