Google interview question

Based on HashMap and Sorting