Tech Mahindra interview question

How to avoid duplicate Objects