Amazon interview question

What is your thinking process? Explain the solution.