Tesco interview question

DSA question based on Array