Amazon interview question

Two programming tests, randomly determined.