<prompt> Write a code to detect duplicates in an array.3, 2, 1, 2, 3, 4  <response>: Heres a Python code that can detect duplicates in an array:pythondef print_duplicatesarr: duplicates_found hashTable for num in arr: if num in hashTable: duplicates_found.appendnum else: hashTablenum num printThe duplicates in the array are:, duplicates_foundinputArray 3, 2, 1, 2, 3, 4print_duplicatesinputArrayOutput:The duplicates in the array are: 2, 3This code uses a hash table to keep track of the elements in the array. When a duplicate is found, i.e., an element is already present in the hash table, it is appended to the duplicates_found list. Finally, this list is printed to display the duplicates in the array. 