Pregunta de entrevista de Cutshort

Pirate Gold Distribution Problem - The algorithm