LiveRamp Interview Question

Just simply analysis the algorithm, running time and optimization would be OK