Domanda di colloquio di Distributed (UK)

I was asked to solve Algorithm Question