Pregunta de entrevista de Amazon

a programming question based on logistics