Amazon interview question

DSA question based on array