HCLTech interview question

Java remove duplicates while adding object to set