Amazon Interview Question

Write a question on your own and solve it