Barclays Interview Question

Coding challenge