Barclays Interview Question

Coding problem statement to solve