PartnerPath interview question

It was a question on algorithm.