## Description

You've been working with a lot of different file types recently as your interests have broadened.

But what file types are you using the most? With this question in mind we look at the following problem.

Given a `List/Array` of Filenames (strings) `files` return a `List/Array of string(s)` contatining the most common extension(s). If there is a tie, return a sorted list of all extensions.

### Important Info:

* Don't forget, you've been working with a lot of different file types, so expect some interesting extensions/file names/lengths in the random tests.
* Filenames and extensions will only contain letters (case sensitive), and numbers.
* If a file has multiple extensions (ie: `mysong.mp3.als`) only count the the last extension (`.als` in this case)


## Examples

```
files = ['Lakey - Better days.mp3', 
         'Wheathan - Superlove.wav', 
         'groovy jam.als', 
         '#4 final mixdown.als', 
         'album cover.ps', 
         'good nights.mp3']
```

would return: `['.als', '.mp3']`, as both of the extensions appear two times in files.

```
files = ['Lakey - Better days.mp3', 
         'Fisher - Stop it.mp3', 
         'Fisher - Losing it.mp3', 
         '#4 final mixdown.als', 
         'album cover.ps', 
         'good nights.mp3']
```
would return `['.mp3']`, because it appears more times then any other extension, and no other extension has an equal amount of appearences.

Difficulty: EASY
Tags: String algorithms

Fundamentals

Data structures
Skill types: Data structures

Starter code:
def solve(files):
	

Solutions:
from collections import Counter
import re

def solve(files):
	c = Counter((re.match('.*(\\.[^.]+)$', fn).group(1) for fn in files))
	m = max(c.values(), default=0)
	return sorted((k for k in c if c[k] == m))


from collections import Counter

def solve(files):
	c = Counter((f[f.rfind('.'):] for f in files))
	MAX = max(c.values(), default=0)
	return sorted((e[0] for e in c.items() if e[1] == MAX))


import os
from collections import Counter

def solve(files):
	c = Counter((os.path.splitext(f)[-1] for f in files))
	m = max(c.values(), default=0)
	return [x for x in sorted(c) if c[x] == m]


def solve(files):
	if not files:
		return files
	d = {}
	for file in files:
		ext = file.split('.')[-1]
		if ext in d:
			d[ext] += 1
		else:
			d[ext] = 0
	m = max(d.values())
	most_used = ['.' + i for (i, j) in list(d.items()) if j == m]
	return sorted(most_used)


solve = lambda f: (lambda l: (lambda d: sorted([e for e in d if d[e] == max(d.values())]))({e: l.count(e) for e in set(l)}))([e[e.rfind('.'):] for e in f])


from collections import Counter as c
from itertools import takewhile

def solve(arr):
	if arr == []:
		return []
	a = sorted(c(map(lambda x: x.split('.')[-1], arr)).most_common(), key=lambda i: (-i[1], i[0]))
	maxi = a[0][1]
	return list(map(lambda x: '.' + x[0], takewhile(lambda x: x[1] == maxi, a)))


from collections import Counter

def solve(files):
	count = Counter((f.rsplit('.')[-1] for f in files))
	m = max(count.values(), default=0)
	return sorted((f'.{ext}' for (ext, c) in count.items() if c == m))


from collections import Counter

def solve(files):
	ext = [f.split('.')[-1] for f in files]
	return sorted(('.' + i for i in set(ext) if ext.count(i) == max((ext.count(i) for i in ext))))


from collections import Counter

def solve(files):
	extensions = Counter(['.' + i.split('.')[-1] for i in files])
	m = max(extensions.values(), default=0)
	return sorted([i for (i, j) in extensions.items() if j == m])


def solve(files):
	hashMap = {}
	mostCommon = []
	maxCount = 1
	for file in files:
		ext = file[file.rfind('.'):]
		count = hashMap[ext] = hashMap.get(ext, 0) + 1
		if maxCount < count:
			maxCount = count
			mostCommon = [ext]
		elif maxCount == count:
			mostCommon.append(ext)
	mostCommon.sort()
	return mostCommon