import sys
def indexOfSmallestElement(lst):
small_num = sys.maxsize
small_num_index = -1
for i in range(len(lst)):
if(lst[i] < small_num):
small_num = lst[i]
small_num_index = i
if(lst[i] == small_num):
if(small_num_index > i):
small_num_index = i
return small_num_index
lst = [1234,12,432,6,112,112]
indexOfSmallestElement(lst)
3
from operator import itemgetter
N=2
def mostCommonName(lst):
counter = {}
for i in range(len(lst)):
if lst[i] not in counter:
counter[lst[i]] = 1
elif lst[i] in counter:
counter[lst[i]] = counter[lst[i]] + 1
print(counter)
max_value = ~sys.maxsize
freq_set = set()
for k, v in counter.items():
if v>1:
if v >= max_value:
if v == max_value:
max_value = v
freq_set.add(k)
elif max_value == v:
freq_set.add(k)
return freq_set
lst = ["Jane", "Aaron", "Jane", "Cindy", "Aaron"]
mostCommonName(lst)
{'Jane': 2, 'Aaron': 2, 'Cindy': 1}
{'Aaron', 'Jane'}