Amazon Interview Question

some debug and algorithms