Amazon Interview Question

Nothing particularly hard.