Edmodo interview question

Leetcode original question, application of data structures and algorithms