UrbanCode interview question

Solve the problem which HR described. Normally a completely data structure and idea back for your implementation