Deliveroo Interview Question

a long exercise about array intersection