Amazon interview question

Nothing to difficult.