Amazon Interview Question

I didn't expect the HR to ask one programming problem