Given an array of names (consisting of lowercase characters) of candidates in an election. A candidate name in array represents a vote casted to the candidate. Print the name of candidate that received Max votes. If there is tie, print lexicographically smaller name.
Example 1:
Input:
n = 13
Votes[] = {john,johnny,jackie,johnny,john 
jackie,jamie,jamie,john,johnny,jamie,
johnny,john}
Output: john 4
Explanation: john has 4 votes casted for 
him, but so does johny. john is 
lexicographically smaller, so we print 
john and the votes he received.
Example 2:
Input:
n = 3
Votes[] = {andy,blake,clark}
Output: andy 1
Explanation: All the candidates get 1 
votes each. We print andy as it is 
lexicographically smaller.
Your Task:
You only need to complete the function winner() that takes an array of strings arr, and n as parameters and returns the name of the candiate with maximum votes and the number of votes the candidate got as an array of size 2.
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(n)
Constraints:
1 <= n <= 10^{5}

Difficulty: EASY
Tags: String algorithms

Data structures
Skill types: Data structures
Expected Time Complexity: O(n)
Expected Auxiliary Space: O(n)

Starter code:
#User function Template for python3

class Solution:
    
    #Complete this function
    
    #Function to return the name of candidate that received maximum votes.
    def winner(self,arr,n):
        # Your code here
        # return the name of the winning candidate and the votes he recieved


Solutions:
class Solution:

	def winner(self, arr, n):
		a = 0
		y = ''
		arr.sort(reverse=True)
		for i in arr:
			if arr.count(i) >= a:
				a = arr.count(i)
				y = i
		return [y, a]


class Solution:

	def winner(self, arr, n):
		max_votes = 0
		d = dict()
		for i in arr:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
			if d[i] > max_votes:
				max_votes = d[i]
		result = []
		for (k, v) in d.items():
			if v == max_votes:
				result.append(k)
		return [sorted(result)[0], max_votes]


class Solution:

	def winner(self, arr, n):
		from collections import Counter
		d = Counter(arr)
		t = []
		r = max(d.values())
		for (k, v) in d.items():
			if v == r:
				t.append(k)
		t.sort()
		return (t[0], arr.count(t[0]))


class Solution:

	def winner(self, arr, n):
		vote_count = {}
		for candidate in arr:
			if candidate in vote_count:
				vote_count[candidate] += 1
			else:
				vote_count[candidate] = 1
		max_votes = 0
		winner = ''
		for (candidate, votes) in vote_count.items():
			if votes > max_votes:
				max_votes = votes
				winner = candidate
			elif votes == max_votes and candidate < winner:
				winner = candidate
		return (winner, max_votes)


from collections import Counter

class Solution:

	def winner(self, arr, n):
		m = Counter(arr)
		votes = list(m.values())
		mx = max(votes)
		a = []
		for i in m:
			if m[i] == mx:
				a.append(i)
		a.sort()
		ans = [a[0], mx]
		return ans


class Solution:

	def winner(self, arr, n):
		hash = {}
		for name in arr:
			if name not in hash:
				hash[name] = 1
			else:
				hash[name] += 1
		max_votes = max(hash.values())
		winner = ''
		for (k, v) in hash.items():
			if v == max_votes:
				if winner != '':
					if winner > k:
						winner = k
				else:
					winner = k
		return [winner, max_votes]


class Solution:

	def winner(self, arr, n):
		dic = dict()
		for i in arr:
			if i in dic:
				dic[i] += 1
			else:
				dic[i] = 1
		m = max(list(dic.values()))
		winners = [k for (k, v) in dic.items() if v == m]
		if len(winners) == 1:
			return (winners[0], m)
		else:
			winners.sort()
			return (winners[0], m)


from collections import OrderedDict

class Solution:

	def winner(self, arr, n):
		mp = OrderedDict({})
		for i in arr:
			mp[i] = mp.get(i, 0) + 1
		maxx = -1
		ans = ''
		mp = OrderedDict(sorted(mp.items()))
		for (key, val) in mp.items():
			if val > maxx:
				maxx = val
				ans = key
		result = [ans, maxx]
		return result


class Solution:

	def winner(self, arr, n):
		from collections import Counter
		vote_count = Counter(arr)
		max_votes = max(vote_count.values())
		winner = min([candidate for candidate in vote_count if vote_count[candidate] == max_votes])
		return (winner, max_votes)


from collections import OrderedDict

class Solution:

	def winner(self, arr, n):
		maxV = -float('inf')
		d = {}
		res = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz'
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
			if d[i] >= maxV:
				if d[i] == maxV and i < res:
					res = i
				elif d[i] > maxV:
					res = i
					maxV = d[i]
		return (res, maxV)


class Solution:

	def winner(self, arr, n):
		d = {}
		for i in arr:
			if i not in d:
				d.update({i: 1})
			else:
				d[i] += 1
		max = -1
		d1 = ''
		b = []
		for i in d.keys():
			if d[i] >= max:
				max = d[i]
		for i in d.keys():
			if d[i] == max:
				b.append(i)
		c = min(b)
		f = []
		f.append(c)
		f.append(max)
		return f


class Solution:

	def winner(self, arr, n):
		dic = {}
		arr.sort()
		m = 1
		for i in arr:
			if i in dic:
				dic[i] += 1
				m = max(m, dic[i])
			else:
				dic[i] = 1
		for i in arr:
			if dic[i] == m:
				return [i, dic[i]]


class Solution:

	def winner(self, arr, n):
		d = {}
		m = 0
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		s = []
		m = max(d.values())
		for (i, j) in d.items():
			if j == m:
				s.append(i)
		s.sort()
		return (s[0], arr.count(s[0]))


class Solution:

	def winner(self, arr, n):
		d = {}
		candidate = []
		for i in arr:
			d[i] = d.get(i, 0) + 1
		maxVote = max(d.values())
		for (key, value) in d.items():
			if value == maxVote:
				candidate.append(key)
		candidate.sort()
		return [candidate[0], maxVote]


class Solution:

	def winner(self, arr, n):
		new = []
		dic = {}
		for i in arr:
			if i in dic:
				dic[i] += 1
			else:
				dic[i] = 1
		m = 1
		for (k, v) in dic.items():
			if v > m:
				m = v
				z = k
		for i in dic:
			if dic[i] == m:
				new.append(i)
		return (min(new), m)


from collections import *

class Solution:

	def winner(self, arr, n):
		vote_counts = defaultdict(int)
		for candidate in arr:
			vote_counts[candidate] += 1
		max_votes = max(vote_counts.values())
		top_candidates = [candidate for candidate in vote_counts if vote_counts[candidate] == max_votes]
		top_candidates.sort()
		return [top_candidates[0], max_votes]


class Solution:

	def winner(self, arr, n):
		arr1 = list(set(arr))
		arr1.sort()
		arr2 = []
		for i in arr1:
			arr2.append(arr.count(i))
		indx = arr2.index(max(arr2))
		return [arr1[indx], max(arr2)]


class Solution:

	def winner(self, arr, n):
		d = {}
		winners = []
		maxVotes = 0
		minn = max(arr)
		for i in arr:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		for (key, value) in d.items():
			if value > maxVotes:
				maxVotes = value
		for (key, value) in d.items():
			if value == maxVotes:
				minn = min(minn, key)
		return [minn, maxVotes]


class Solution:

	def winner(self, arr, n):
		d = {}
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		d1 = sorted(d.values())
		x = d1[-1]
		ppp = []
		for i in d:
			if d[i] == x:
				ppp.append(i)
		ppp.sort()
		return (ppp[0], x)


from collections import Counter
from collections import defaultdict

class Solution:

	def winner(self, arr, n):
		d = defaultdict(list)
		for (k, v) in Counter(arr).items():
			d[v].append(k)
		count = max(d)
		person = min(d[count])
		return (person, count)


from collections import Counter
from collections import defaultdict

class Solution:

	def winner(self, arr, n):
		c = Counter(arr)
		tpls = sorted(list(c.items()), key=lambda x: x[1], reverse=True)
		mx = max(tpls, key=lambda x: x[1])[1]
		people = []
		for (name, count) in tpls:
			if count == mx:
				people.append(name)
			else:
				break
		return (min(people), mx)


class Solution:

	def winner(self, arr, n):
		d = {}
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		votes = list(d.values())
		max_votes = max(votes)
		w = {}
		for j in d:
			if d[j] == max_votes:
				w[j] = max_votes
		winner = list(w.keys())
		winner.sort()
		return (winner[0], max_votes)


class Solution:

	def winner(self, arr, n):
		dic = {}
		for i in arr:
			if i not in dic:
				dic[i] = 1
			else:
				dic[i] += 1
		v = -1
		name = ''
		for i in dic:
			if v < dic[i]:
				v = dic[i]
				name = i
			elif v == dic[i]:
				if name > i:
					v = dic[i]
					name = i
		return [name, v]


from collections import Counter

class Solution:

	def winner(self, arr, n):
		l = []
		c = Counter(arr)
		m = max(c.values())
		for (i, j) in c.items():
			if j == m:
				l.append(i)
		l.sort()
		return (l[0], arr.count(l[0]))


class Solution:

	def winner(self, arr, n):
		vote = dict()
		for ele in arr:
			if ele in vote.keys():
				vote[ele] += 1
			else:
				vote[ele] = 1
		winner = [None, 0]
		for ele in vote:
			if vote[ele] > winner[1]:
				winner[0] = ele
				winner[1] = vote[ele]
			if vote[ele] == winner[1]:
				if ele < winner[0]:
					winner[0] = ele
		return winner


class Solution:

	def winner(self, arr, n):
		dic = {}
		res = []
		for v in arr:
			if v not in dic:
				dic[v] = 1
			else:
				dic[v] += 1
		max_vote = 0
		winner = ''
		for k in dic:
			if dic[k] > max_vote:
				max_vote = dic[k]
				winner = k
			elif dic[k] == max_vote and k < winner:
				winner = k
		return [winner, max_vote]


class Solution:

	def winner(self, arr, n):
		hash_map = {}
		for i in arr:
			if i not in hash_map:
				hash_map[i] = 1
			else:
				hash_map[i] += 1
		m = -2 ** 31
		n = None
		for i in sorted(hash_map):
			if hash_map[i] > m:
				m = hash_map[i]
				n = i
		return (n, m)


class Solution:

	def winner(self, arr, n):
		d = {}
		for i in arr:
			d[i] = 0
		for i in arr:
			d[i] += 1
		maxi = 0
		L = []
		for i in d:
			if d[i] > maxi:
				maxi = d[i]
		for i in d:
			if d[i] == maxi:
				L.append(i)
		L.sort()
		return (L[0], maxi)


from collections import *

class Solution:

	def winner(self, arr, n):
		res = []
		a = Counter(arr)
		val = max(a.values())
		for i in arr:
			if a[i] == val:
				res.append(i)
		res.sort()
		return (res[0], arr.count(res[0]))


class Solution:

	def winner(self, arr, n):
		d = {}
		for i in arr:
			d[i] = d.get(i, 0) + 1
		ans = [i for (i, values) in d.items() if values == max(d.values())]
		ans.sort()
		return [ans[0], d[ans[0]]]


class Solution:

	def winner(self, arr, n):
		votes = {}
		win = []
		for i in arr:
			if i in votes:
				votes[i] += 1
			else:
				votes[i] = 1
		maxVotes = 0
		for i in votes:
			key = i
			value = votes[i]
			if value > maxVotes:
				maxVotes = value
				winner = key
			elif maxVotes == value and winner > key:
				winner = key
		win.append(winner)
		win.append(maxVotes)
		return win


class Solution:

	def winner(self, arr, n):
		arr_1 = list(arr)
		list_a = sorted(set(arr))
		count_list = []
		for i in range(len(list_a)):
			count = arr_1.count(list_a[i])
			count_list.append(count)
		index_count = count_list.index(max(count_list))
		return (list_a[index_count], max(count_list))


class Solution:

	def winner(self, arr, n):
		d = {}
		for i in range(n):
			if arr[i] not in d:
				d[arr[i]] = 1
			else:
				d[arr[i]] += 1
		m = 0
		for i in d:
			if d[i] > m:
				m = d[i]
		s = []
		for i in d:
			if d[i] == m:
				s.append(i)
		l = [min(s), m]
		return l


from collections import Counter

class Solution:

	def winner(self, arr, n):
		hashmap = Counter(arr)
		result = []
		max_val = max(hashmap.values())
		for i in hashmap:
			if hashmap[i] == max_val:
				result.append(i)
		result.sort()
		return [result[0], max_val]


class Solution:

	def winner(self, arr, n):
		D = {0: 0}
		for i in arr:
			D[i] = D.get(i, 0) + 1
		max = 0
		for i in D.keys():
			if D[max] < D[i]:
				max = i
			elif D[max] == D[i] and max > i:
				max = i
		return (max, D[max])


class Solution:

	def winner(self, arr, n):
		res = {}
		for name in arr:
			if name not in res:
				res[name] = 1
			else:
				res[name] += 1
		max_vote = 0
		lst = []
		for (key, value) in res.items():
			if value > max_vote:
				max_vote = value
		for (key, value) in res.items():
			if value == max_vote:
				lst.append(key)
		lst.sort()
		key = lst[0]
		return (key, res[key])


class Solution:

	def winner(self, arr, n):
		d = {i: 0 for i in arr}
		for x in arr:
			d[x] += 1
		t = []
		maxx = max(d.values())
		for (x, y) in d.items():
			if y == maxx:
				t.append(x)
		t.sort()
		return (t[0], d[t[0]])
		return max_pair


from collections import Counter

class Solution:

	def winner(self, arr, n):
		d = Counter(arr)
		t = []
		maxx = max(d.values())
		for (x, y) in d.items():
			if y == maxx:
				t.append(x)
		t.sort()
		return (t[0], d[t[0]])
		return max_pair


class Solution:

	def winner(self, arr, n):
		voting = []
		count = [0 for i in range(n)]
		i = 0
		for name in arr:
			if name not in voting:
				voting.append(name)
				count[i] = 1
				i += 1
			else:
				j = 0
				while name != voting[j]:
					j += 1
				count[j] += 1
		res = []
		fin = []
		max = 0
		for i in range(len(voting)):
			if max <= count[i]:
				max = count[i]
		for i in range(len(voting)):
			if max == count[i]:
				res.append(voting[i])
		res.sort()
		count.sort(reverse=True)
		fin.append(res[0])
		fin.append(count[0])
		return fin


class Solution:

	def winner(self, arr, n):
		map = {}
		for candidate in arr:
			if candidate in map:
				map[candidate] += 1
			else:
				map[candidate] = 1
		votes = list(map.values())
		max_vote = max(votes)
		winners = {}
		for ele in map:
			if map[ele] == max_vote:
				winners[ele] = max_vote
		winner_names = list(winners.keys())
		winner_names.sort()
		return (winner_names[0], winners[winner_names[0]])


class Solution:

	def winner(self, arr, n):
		votes_count = dict()
		for name in arr:
			curr_votes = votes_count.setdefault(name, 0)
			votes_count[name] = curr_votes + 1
		sorted_names_count = [None] * n
		for (name, votes) in votes_count.items():
			p_name = sorted_names_count[votes - 1]
			if p_name is not None:
				if name < p_name:
					sorted_names_count[votes - 1] = name
			else:
				sorted_names_count[votes - 1] = name
		for i in range(len(sorted_names_count) - 1, -1, -1):
			name = sorted_names_count[i]
			if name:
				return (name, i + 1)


class Solution:

	def winner(self, arr, n):
		freq = {}
		for i in arr:
			if i not in freq:
				freq[i] = 0
			freq[i] += 1
		mi = 'zzzzzzzzz'
		ma = 0
		for i in freq:
			if freq[i] > ma:
				ma = freq[i]
				mi = i
			elif freq[i] == ma:
				mi = min(mi, i)
		return (mi, ma)


import collections

class Solution:

	def winner(self, arr, n):
		dict1 = collections.Counter(arr)
		list1 = [i for i in dict1 if dict1[i] == max(dict1.values())]
		list2 = [min(list1), dict1[min(list1)]]
		return list2


class Solution:

	def winner(self, arr, n):
		votes = {}
		max_votes = 0
		for ele in arr:
			if ele not in votes:
				votes[ele] = 1
			else:
				votes[ele] += 1
			max_votes = max(max_votes, votes[ele])
		max_can = ''
		for (key, value) in votes.items():
			if value == max_votes:
				if max_can == '':
					max_can = key
				else:
					max_can = min(max_can, key)
		return (max_can, max_votes)


from collections import Counter

class Solution:

	def winner(self, arr, n):
		c = Counter(arr)
		max = ['', 0]
		for (k, v) in c.items():
			if v > max[1]:
				max[0] = k
				max[1] = v
			elif v == max[1]:
				if k < max[0]:
					max[0] = k
		return max


class Solution:

	def winner(self, arr, n):
		data = {}
		maxx = 0
		for each in arr:
			if each in data:
				data[each] += 1
			else:
				data[each] = 1
			maxx = max(data[each], maxx)
		res = []
		for (i, j) in data.items():
			if j == maxx:
				res.append([i, j])
		res.sort()
		return [res[0][0], res[0][1]]


class Solution:

	def winner(self, arr, n):
		d = {}
		for i in arr:
			if i not in d:
				d[i] = arr.count(i)
		a = [i for i in d if d[i] == max(d.values())]
		a.sort()
		return (a[0], max(d.values()))


class Solution:

	def winner(self, arr, n):
		arr.sort()
		l = []
		d = {}
		l1 = []
		s1 = ''
		for i in arr:
			if i not in d:
				d[i] = 1
			else:
				d[i] += 1
		for i in d:
			l.append(d[i])
		m = max(l)
		for i in d:
			if d[i] == m:
				l1.append((i, d[i]))
		l1.sort()
		m = l1[0]
		return m


class Solution:

	def winner(self, arr, n):
		dic = {}
		high = 0
		finalList = []
		for i in range(n):
			cnt = arr.count(arr[i])
			if cnt > high:
				high = cnt
			if arr[i] not in dic:
				dic[arr[i]] = cnt
		for (name, vote) in dic.items():
			if vote == high:
				finalList.append(name)
		finalList.sort()
		res = []
		res.append(finalList[0])
		res.append(high)
		return res


class Solution:

	def winner(self, arr, n):
		hmap = {}
		res = ''
		curr = 0
		for val in arr:
			hmap[val] = hmap.get(val, 0) + 1
			if hmap[val] > curr:
				curr = hmap[val]
				res = val
			elif hmap[val] == curr:
				if res < val:
					continue
				else:
					res = val
		return (res, curr)


class Solution:

	def winner(self, arr, n):
		dic = {}
		for i in arr:
			if i in dic:
				dic[i] += 1
			else:
				dic[i] = 1
		k = max(dic.values())
		a = []
		for (i, j) in dic.items():
			if j == k:
				a += [[i, j]]
		a.sort()
		return a[0]


class Solution:

	def winner(self, arr, n):
		votes = {}
		for i in range(n):
			if arr[i] in votes.keys():
				votes[arr[i]] += 1
			else:
				votes[arr[i]] = 1
		majority = 0
		for (k, v) in votes.items():
			if v > -1:
				majority = max(majority, v)
		m = max(sorted(votes), key=votes.get)
		return (m, majority)


class Solution:

	def winner(self, arr, n):
		d = {}
		for i in arr:
			if i not in d:
				d[i] = 0
			d[i] += 1
		max_votes = max(d.values())
		winner = []
		for (key, votes) in d.items():
			if max_votes == votes:
				winner.append(key)
		return (min(winner), max_votes)


class Solution:

	def winner(self, arr, n):
		votes = sorted(arr, key=lambda i: len(i))
		dic = {}
		for i in votes:
			if i in dic:
				dic[i] += 1
			else:
				dic[i] = 1
		new = list(dic.values())
		mx = max(new)
		lst = []
		for (q, w) in dic.items():
			if w == mx:
				lst += [[q, w]]
		a = sorted(lst, key=lambda lst: lst[0])
		return a[0]


class Solution:

	def winner(self, arr, n):
		l = []
		arr = sorted(arr)
		l = [arr.count(arr[i]) for i in range(n)]
		return (arr[l.index(max(l))], max(l))


class Solution:

	def winner(self, arr, n):
		from collections import Counter
		dict = Counter(arr)
		max = 0
		res = []
		for i in dict:
			if dict[i] > max:
				max = dict[i]
		for i in dict:
			if dict[i] == max:
				res.append(i)
		curr = res[0]
		for i in res:
			if i < curr:
				curr = i
		result = [curr, dict[curr]]
		return result


class Solution:

	def winner(self, arr, n):
		d = dict()
		for i in arr:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		r = max(d.values())
		t = []
		for (k, v) in d.items():
			if v == r:
				t.append(k)
		t.sort()
		return (t[0], arr.count(t[0]))


class Solution:

	def winner(self, arr, n):
		d = {}
		for i in range(n):
			if arr[i] in d:
				d[arr[i]] += 1
			else:
				d[arr[i]] = 1
		name = ''
		name_c = 0
		for (i, j) in d.items():
			if j > name_c:
				name = i
				name_c = j
			elif j == name_c and i < name:
				name = i
				name_c = j
		return [name, name_c]


class Solution:

	def winner(self, arr, n):
		dict = {}
		for i in range(len(arr)):
			if arr[i] in dict:
				dict[arr[i]] += 1
			else:
				dict[arr[i]] = 1
		max_count = max(dict.values())
		my_dict = {}
		list = sorted([i for i in dict.keys() if dict[i] == max_count])
		return (list[0], max_count)


class Solution:

	def winner(self, arr, n):
		k = arr.copy()
		dic = {}
		lis = []
		for i in arr:
			if i not in dic:
				dic[i] = 1
			else:
				dic[i] += 1
		fre = {}
		for i in dic:
			if dic[i] not in fre:
				fre[dic[i]] = [i]
				lis.append(dic[i])
			else:
				fre[dic[i]].append(i)
		lis.sort()
		if lis[-1] == 1:
			k.sort()
			return (k[0], 1)
		fre[lis[-1]].sort()
		j = fre[lis[-1]]
		return (j[0], lis[-1])


class Solution:

	def winner(self, arr, n):
		d = {}
		dist = []
		for i in arr:
			if i in d:
				d[i] += 1
			else:
				d[i] = 1
		max = 0
		name = ''
		for i in d:
			if d[i] > max:
				max = d[i]
				name = i
			elif d[i] == max:
				if i < name:
					max = d[i]
					name = i
		return (name, max)


class Solution:

	def winner(self, arr, n):
		vote = {}
		for i in arr:
			if i in vote.keys():
				vote[i] += 1
			else:
				vote[i] = 1
		maxVal = 0
		for i in set(vote.values()):
			if i > maxVal:
				maxVal = i
		winners = []
		for (i, j) in vote.items():
			if j == maxVal:
				winners.append(i)
		minWord = min(winners)
		return (minWord, maxVal)


from collections import Counter

class Solution:

	def winner(self, arr, n):
		d = Counter(arr)
		t = []
		mx = max(d.values())
		for (i, j) in d.items():
			if j == mx:
				t.append(i)
		t.sort()
		return (t[0], arr.count(t[0]))


class Solution:

	def winner(self, arr, n):
		hmp = {}
		for i in arr:
			if i not in hmp.keys():
				hmp[i] = 0
			hmp[i] += 1
		max = 0
		winner = ''
		for x in hmp:
			k = x
			val = hmp[x]
			if val > max:
				max = val
				winner = k
			elif val == max and winner > k:
				winner = k
		return [winner, max]


class Solution:

	def winner(self, arr, n):
		if len(set(arr)) == n:
			arr.sort()
			return [arr[0], 1]
		d = {}
		mx = 0
		for i in arr:
			if i in d:
				d[i] += 1
				if d[i] > mx:
					mx = d[i]
			else:
				d[i] = 1
		l = []
		for i in d:
			if d[i] == mx:
				l.append(i)
		l.sort()
		return [l[0], mx]


class Solution:

	def winner(self, arr, n):
		d = {}
		maxName = None
		maxVotes = 0
		for a in arr:
			if a not in d:
				d[a] = 1
			else:
				d[a] = d[a] + 1
			if d[a] > maxVotes:
				maxVotes = d[a]
				maxName = a
			elif d[a] == maxVotes:
				if a < maxName:
					maxVotes = d[a]
					maxName = a
		return [maxName, maxVotes]


class Solution:

	def winner(self, arr, n):
		hashmap = {}
		l = []
		for i in arr:
			hashmap[i] = hashmap.get(i, 0) + 1
		so = max(sorted(hashmap.values()))
		for (i, j) in sorted(hashmap.items()):
			if j == so:
				l.append([i, j])
		return l[0]


class Solution:

	def winner(self, arr, n):
		mp = dict()
		ans = 0
		result = ''
		for ele in arr:
			if ele not in mp:
				mp[ele] = 1
			else:
				mp[ele] += 1
		for ele in mp:
			if mp[ele] > ans:
				ans = mp[ele]
				result = ele
			elif mp[ele] == ans and result > ele:
				result = ele
		return [result, ans]


class Solution:

	def winner(self, arr, n):
		dict1 = {}
		for i in range(n):
			if arr[i] not in dict1:
				dict1[arr[i]] = 1
			else:
				dict1[arr[i]] += 1
		max_votes = max(dict1.values())
		temp = [name for (name, votes) in dict1.items() if votes == max_votes]
		return (min(temp), max_votes)


class Solution:

	def winner(self, arr, n):
		max = {'name': '', 'count': 0}
		voteCount = {}
		for i in arr:
			if i not in voteCount:
				voteCount[i] = 0
			voteCount[i] += 1
			if max['count'] < voteCount[i]:
				max['count'] = voteCount[i]
				max['name'] = i
			elif max['count'] == voteCount[i]:
				max['name'] = max['name'] if i > max['name'] else i
		return (max['name'], max['count'])


class Solution:

	def winner(self, arr, n):
		d = dict()
		a = ''
		for i in arr:
			d[i] = d.get(i, 0) + 1
		count = float('-inf')
		l = sorted(list(d))
		for i in l:
			if d[i] > count:
				count = d[i]
				a = i
		return (a, count)


class Solution:

	def winner(self, arr, n):
		d = dict()
		z = []
		for ele in arr:
			d[ele] = 0
		for ele in arr:
			d[ele] = d[ele] + 1
		for ele in d.keys():
			a = max(d.values())
			if d[ele] == a:
				z.append(ele)
		z.sort()
		return (z[0], a)


from collections import OrderedDict

class Solution:

	def winner(self, arr, n):
		m = OrderedDict()
		ans = []
		for i in range(n):
			if arr[i] not in m:
				m[arr[i]] = 1
			else:
				m[arr[i]] += 1
		max = 0
		for j in m.keys():
			if m[j] > max:
				max = m[j]
				ans = [j]
			elif m[j] == max:
				ans.append(j)
		ans.sort()
		return (ans[0], max)


class Solution:

	def winner(self, arr, n):
		hash_map = {}
		for i in arr:
			if i not in hash_map.keys():
				hash_map[i] = 1
			else:
				hash_map[i] = hash_map[i] + 1
		max_val = max(hash_map.values())
		for i in sorted(hash_map.keys()):
			if hash_map[i] == max_val:
				return [i, hash_map[i]]


from collections import OrderedDict

class Solution:

	def winner(self, arr, n):
		arr.sort()
		max = 0
		dict = OrderedDict()
		for i in arr:
			if i in dict:
				dict[i] += 1
				if dict[i] > max:
					max = dict[i]
			else:
				dict[i] = 1
				if dict[i] > max:
					max = dict[i]
		for j in dict:
			if dict[j] == max:
				return [j, max]