Pergunta de entrevista da empresa Mars

Technical interview was based on an example problem