Amazon Interview Question

Some Puzzle