Wavelio interview question

Not difficult