Amazon interview question

dsa question from array manipulation and set operation