Given an array, find the duplicates in that array, and return a new array of those duplicates. The elements of the returned array should appear in the order when they first appeared as duplicates.

__*Note*__: numbers and their corresponding string representations should not be treated as duplicates (i.e., `"1" != 1`).

## Examples
```
[1, 2, 4, 4, 3, 3, 1, 5, 3, "5"]  ==>  [4, 3, 1]
[0, 1, 2, 3, 4, 5]                ==>  []
```

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Data structures

Starter code: def duplicates(array):
	

Solutions:
def duplicates(array):
	seen = []
	dups = []
	for char in array:
		if char not in seen:
			seen.append(char)
		elif char not in dups:
			dups.append(char)
	return dups


def duplicates(arr):
	res = []
	for (i, x) in enumerate(arr):
		if arr[:i + 1].count(x) > 1 and x not in res:
			res.append(x)
	return res


def duplicates(array):
	dub = []
	for (i, el) in enumerate(array):
		if i != array.index(el) and el not in dub:
			dub.append(el)
	return dub


def duplicates(array):
	return [n for (i, n) in enumerate(array) if array[:i].count(n) == 1]


from typing import List, Union

def duplicates(array: List[Union[int, str]]) -> List[Union[int, str]]:
	(d, res) = ({}, [])
	for a in array:
		if d.setdefault(a, 0) == 1:
			res.append(a)
		d[a] += 1
	return res


from collections import defaultdict

def duplicates(lst):
	result = []
	counter = defaultdict(int)
	for elem in lst:
		counter[elem] += 1
		if counter[elem] == 2:
			result.append(elem)
	return result


def duplicates(array):
	return [v for (i, v) in enumerate(array) if v in array[:i] and array[:i].count(v) == 1]


def duplicates(array):
	result = []
	for (i, v) in enumerate(array):
		if v in array[:i] and v not in result:
			result.append(v)
	return result


def duplicates(array):
	(l, out) = ([], [])
	for e in array:
		if e in l and e not in out:
			out.append(e)
		l.append(e)
	return out