Amazon interview question

One DSA coding problem and it was difficult