Citi Interview Question

How did you implement the solution?