Amazon Interview Question

Typical algorithm complexity questions. Not difficult.