Microsoft interview question

Coding interview on the codility platform