Spotify Interview Question

Data structure, Big O notations, optimisation