IXL Learning Interview Question

Leetcode question, not too hard