Amazon Interview Question

Easy alghoritmic programming question to solve