IXL Learning interview question

Pretty basic algos