Amazon Interview Question

a concept from slidign window