Amazon Interview Question

Porblem about design pattern