Question d’entretien chez Distributed (UK)

I was asked to solve Algorithm Question