Google interview question

Just some hints. Iterator of Iterators. HashMap. Subsets. Binary Tree.