IXL Learning Interview Question

Leetcode medium to hard, just do blind 75