Amazon Interview Question

a programming question based on logistics