Pergunta de entrevista da empresa Bayer

Solved two basic algorithm questions