Distributed (UK) Interview Question

I was asked to solve Algorithm Question