Tech Mahindra Interview Question

How to avoid duplicate Objects