Amazon interview question

They asked to solve a DS Alg problem