Barclays interview question

coding was 4 questions, leetcode mediums