Problem AKBAR

Can someone help with the implementation of this problem. I have understood the concept but having problem implementing it.

Thanks.