Amazon Interview Question

Cannot really discuss these problems.