Your task is to implement a function that takes one or more dictionaries and combines them in one result dictionary.

The keys in the given dictionaries can overlap. In that case you should combine all source values in an array. Duplicate values should be preserved.

Here is an example:
```cs
var source1 = new Dictionary{{"A", 1}, {"B", 2}}; 
var source2 = new Dictionary{{"A", 3}};

Dictionary result = DictionaryMerger.Merge(source1, source2);
// result should have this content: {{"A", [1, 3]}, {"B", [2]}}

```
```python
source1 = {"A": 1, "B": 2} 
source2 = {"A": 3}

result = merge(source1, source2);
// result should have this content: {"A": [1, 3]}, "B": [2]}

```

You can assume that only valid dictionaries are passed to your function.
The number of given dictionaries might be large. So take care about performance.

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def merge(*dicts):
	

Solutions:
def merge(*dicts):
	result = {}
	for d in dicts:
		for (key, value) in d.items():
			result.setdefault(key, []).append(value)
	return result
from itertools import groupby, chain


from collections import defaultdict

def merge(*dicts):
	d = defaultdict(list)
	for dd in dicts:
		for (k, v) in dd.items():
			d[k].append(v)
	return d


def merge(*dicts):
	r = {}
	for d in dicts:
		for k in d:
			r[k] = r.get(k, []) + [d[k]]
	return r


def merge(*dicts):
	keys = set([key for d in dicts for key in d])
	return {key: [d[key] for d in dicts if key in d] for key in keys}


from collections import defaultdict

def merge(*dicts):
	d = defaultdict(list)
	[d[key].append(value) for dictionary in dicts for (key, value) in list(dictionary.items())]
	return d


def merge(*dicts):
	merged = {}
	for dict in dicts:
		for (key, value) in dict.items():
			if key not in merged:
				merged[key] = [value]
			else:
				merged[key].append(value)
	return merged


def merge(*dcts):
	return {k: [dct[k] for dct in dcts if k in dct] for dct in dcts for k in dct}


def merge(*dicts):
	merged = {}
	for dict in dicts:
		for (k, v) in dict.items():
			merged.setdefault(k, []).append(v)
	return merged


from collections import defaultdict

def merge(*dcts):
	result = defaultdict(list)
	for dct in dcts:
		for (k, v) in list(dct.items()):
			result[k].append(v)
	return result


def merge(*dicts):
	r = {}
	for d in dicts:
		for (k, v) in d.items():
			if k in r:
				r[k].append(v)
			else:
				r[k] = [v]
	return r