Amazon interview question

Data structures and algorithms qs