Google interview question

based on data structures and algo