Amazon interview question

a programming question based on logistics