How do you find duplicate elements in an array using a hash map, and what is the time complexity of this approach?