Amazon interview question

Simple algorithm questions