Amazon Interview Question

Basic coding questions, a lot of algorithm analysis