Bayer interview question

Solved two basic algorithm questions