IXL Learning interview question

Leecode easy to medium, nothing crazy