Amazon interview question

How would you approach this problem