Goal
Given a list of elements [a1, a2, ..., an], with each ai being a string, write a function **majority** that returns the value that appears the most in the list. 

If there's no winner, the function should return None, NULL, nil, etc, based on the programming language.

Example
majority(["A", "B", "A"]) returns "A"
majority(["A", "B", "B", "A"]) returns None

Source: codewars | Difficulty: EASY
Tags: Fundamentals

Starter code: def majority(arr):
	

Solutions:
from collections import Counter

def majority(arr):
	mc = Counter(arr).most_common(2)
	if arr and (len(mc) == 1 or mc[0][1] != mc[1][1]):
		return mc[0][0]


def majority(arr):
	dic = {}
	n = 0
	c = 0
	for x in arr:
		if not x in dic:
			dic[x] = 1
		else:
			dic[x] += 1
	for x in dic:
		n = max(n, dic[x])
	for x in dic:
		if dic[x] == n:
			r = x
			c += 1
	if c == 1:
		return r
	else:
		return None


from collections import Counter

def majority(arr):
	c = Counter(arr).most_common(2) + [(0, 0)] * 2
	if c[0][1] != c[1][1]:
		return c[0][0]


def majority(arr):
	cnt = sorted(([arr.count(i), i] for i in set(arr)), reverse=True)
	if len(cnt) == 1 or (len(cnt) > 1 and cnt[0][0] != cnt[1][0]):
		return cnt[0][1]
	else:
		return None


def majority(arr):
	d = {elem: arr.count(elem) for elem in arr}
	l = [k for (k, v) in list(d.items()) if v == max(d.values())]
	return l[0] if len(l) == 1 else None


from collections import Counter

def majority(arr):
	m = Counter(arr).most_common(2)
	return None if len(arr) == 0 or (len(m) == 2 and m[0][1] == m[1][1]) else m[0][0]


from collections import Counter

def majority(arr):
	counter = Counter(arr)
	best = counter.most_common(2)
	if not best:
		return None
	elif len(best) == 1 or best[0][1] != best[1][1]:
		return best[0][0]


from collections import Counter

def majority(arr):
	c = Counter(arr)
	t = c.most_common(2)
	if len(t) == 1 or (len(t) > 1 and t[1][1] < t[0][1]):
		return t[0][0]
	return None


from collections import Counter

def majority(arr):
	try:
		c = Counter(arr)
		val = list(c.values())
		assert val.count(max(val)) == 1
		return sorted([(v, k) for (k, v) in list(c.items())], reverse=True)[0][1]
	except:
		return None


from collections import *

def majority(arr):
	for (k, v) in list(Counter(arr).items()):
		if len(Counter(arr)) == 1:
			return k
		elif v > max([j for (i, j) in list(Counter(arr).items()) if i != k]):
			return k