Ablacon interview question

An algorithmic coding problem that I was supposed to solve in an online document