Amazon interview question

One simple and one complex coding question.