Amazon interview question

Porblem about design pattern