You are asking for code? That means you must have completed your requirements, which include a description of how to identify duplicate elements.
But if you think about it, we don't know what you decided there. So asking for code to do that is rather useless. Why don't you post the rules for identifying duplicate elements, and we can discuss that? Don't expect anybody to write the code for you, though, that isn't how this forum works.