Amazon interview question

How would you walk through this problem