LinkedIn Interview Question

What data structure would be best fitted for this piece of code?