Amazon Interview Question

5 island problem was asked from me.